Exemplo n.º 1
0
def main():
    idb = innodb.InnoDB()
    test0aux.test_configure()
    idb.startup('barracuda')

    pprint(idb.getOptionDict())
    pprint(idb.getStatusDict())

    idb.shutdown()
Exemplo n.º 2
0
def main():
    txn = innodb.Transaction(libinnodb.IB_TRX_REPEATABLE_READ)
    print 'API: %d.%d.%d' % innodb.api_version()
    idb = innodb.InnoDB()
    test0aux.test_configure()
    idb.startup('barracuda')
    db = idb[DATABASE]
    db.create()
    print 'Create table'
    table = db[TABLE]
    create_table(txn, table)
    print 'Begin transaction'
    txn.begin()
    print 'Open cursor'
    crsr = table.open(txn)
    print 'Lock table in IX'
    crsr.lockTable(libinnodb.IB_LOCK_IX)
    print 'Insert rows'
    crsr.insertRows((
        ('a', 't', 1),
        ('b', 'u', 2),
        ('c', 'b', 3),
        ('d', 'n', 4),
        ('e', 's', 5),
        ('e', 'j', 6),
        ('d', 'f', 7),
        ('c', 'n', 8),
        ('b', 'z', 9),
        ('a', 'i', 10),
    ))
    print 'Query table'
    do_query(crsr)
    print 'Update a row'
    update_a_row(crsr)
    print 'Query table'
    do_query(crsr)
    print 'Delete a row'
    delete_a_row(crsr)
    print 'Query table'
    do_query(crsr)
    print 'Close cursor'
    crsr.close()
    print 'Commit transaction'
    txn.commit()
    print 'Drop table'
    txn.begin()
    txn.lockSchema(True)
    table.drop(txn)
    txn.commit()
    idb.shutdown()
Exemplo n.º 3
0
def main():
    idb = innodb.InnoDB()
    test0aux.test_configure()
    idb.startup('barracuda')
    db = idb[DATABASE]
    db.create()
    table = db[TABLE]
    txn = innodb.Transaction(libinnodb.IB_TRX_REPEATABLE_READ)
    create_table(txn, table)
    txn.begin()
    crsr = table.open(txn)
    crsr.lockTable(libinnodb.IB_LOCK_IX)
    insert_rows(crsr)
    print 'SELECT * FROM T;'
    crsr.goFirst()
    iterate(crsr, print_all)
    print 'SELECT * FROM T WHERE c1 = 5;'
    tpl = crsr.getSearchTuple()
    tpl[0] = 5
    crsr.goTo(tpl, libinnodb.IB_CUR_GE)
    iterate(crsr, print_eq_5)
    print 'SELECT * FROM T WHERE c1 > 5;'
    crsr.goTo(tpl, libinnodb.IB_CUR_G)
    iterate(crsr, print_all)
    print 'SELECT * FROM T WHERE c1 < 5;'
    crsr.goFirst()
    iterate(crsr, print_lt_5)
    print 'SELECT * FROM T WHERE c1 >= 1 AND c1 < 5;'
    tpl = crsr.getSearchTuple()
    tpl[0] = 1
    crsr.goTo(tpl, libinnodb.IB_CUR_GE)
    iterate(crsr, print_lt_5)
    crsr.close()
    txn.commit()
    txn.begin()
    txn.lockSchema(True)
    table.drop(txn)
    txn.commit()
    idb.shutdown()
Exemplo n.º 4
0
def main():
    crsr = libinnodb.ib_crsr_t()
    ib_trx = libinnodb.ib_trx_t()
    print 'API: %d.%d.%d' % innodb.api_version()
    innodb.init()
    test0aux.test_configure()
    innodb.startup('barracuda')
    innodb.database_create(DATABASE)
    print 'Create table'
    create_table(DATABASE, TABLE)
    print 'Begin transaction'
    ib_trx = innodb.trx_begin(libinnodb.IB_TRX_REPEATABLE_READ)
    assert ib_trx
    print 'Open cursor'
    open_table(DATABASE, TABLE, ib_trx, crsr)
    print 'Lock table in IX'
    innodb.cursor_lock(crsr, libinnodb.IB_LOCK_IX)
    print 'Insert rows'
    insert_rows(crsr)
    print 'Query table'
    do_query(crsr)
    print 'Update a row'
    update_a_row(crsr)
    print 'Query table'
    do_query(crsr)
    print 'Delete a row'
    delete_a_row(crsr)
    print 'Query table'
    do_query(crsr)
    print 'Close cursor'
    innodb.cursor_close(crsr)
    print 'Commit transaction'
    innodb.trx_commit(ib_trx)
    print 'Drop table'
    test0aux.drop_table(DATABASE, TABLE)
    innodb.shutdown(libinnodb.IB_SHUTDOWN_NORMAL)