Connection.startTransaction

Start a database transaction on this connection.

For an overview see page Python Connection Class

Prototype

 
    Connection.startTransaction(type, priority)
 

Arguments

type

The Transaction Type; one of the following values:

 
    MCO_READ_ONLY = 0
    MCO_UPDATE = 1
    MCO_READ_WRITE = 2
    MCO_EXCLUSIVE = 3
 
priority

The Transaction Priority; one of the following values:

 
    MCO_TRANS_IDLE       = -2
    MCO_TRANS_BACKGROUND = -1
    MCO_TRANS_FOREGROUND = 0
    MCO_TRANS_HIGH       = 1
    MCO_TRANS_ISR        = 2
 

Description

This method starts a database transaction on this Connection. Note that nested transactions are not supported, so each connection can have only one opened transaction at a time.

Returns

MCO_S_OK Transaction started successfully
Exception An exception is thrown with the appropriate error message

Example

     
    conn = db.connect()
    print 'Database connected. Connection object is', conn
    #
    # Insert objects
    #
    i = 0
    while i < OBJECT_NUM:
        conn.startTransaction(exdb.Transaction.MCO_READ_WRITE) # start RW transaction
        rec = conn.new("Record") # create python object
        # fill data
        ...
 
        conn.commit() # commit changes
        i += 1
 
    print_database(conn, "Database content after insert :")