[pybsddb] Problems with Transactions

Allan Spale allan2600 at gmail.com
Fri Jul 4 06:34:58 CEST 2008


I am running Python 2.5 (stackless) on Windows XP with the default
installation of BerkeleyDB (version 4.4.20). What might be relevant is
that I installed version 4.7.1, but did not update anything in my
Python directories, and I am not fully sure where the Python
installation is looking to find its default 4.4.20 version of

My problem is that I am having great difficulty trying to do a simple
transaction. I am probably making a simple mistake, but I cannot
determine why I might be getting this error. As a side note, I am not
interested using locks at this time. Any help would be appreciated in
figuring out what the error message means and how to avoid receiving
this error in the future (as seen in the Python session below).


>>> from bsddb import db
>>> env_flags = db.DB_CREATE | db.DB_INIT_LOG | db.DB_INIT_MPOOL | db.DB_INIT_TXN
>>> db_flags = db.DB_CREATE
>>> env = db.DBEnv(0)
>>> env.open('c:\\temp\\test', env_flags, 0)
>>> mydb = db.DB(env, 0)
>>> mydb.open(None, 'test123.db', db.DB_BTREE, db_flags, 0)
>>> mydb.put('1','2')
>>> mydb.get('1')
>>> txn = env.txn_begin()
>>> txn
<DBTxn object at 0x00A80278>
>>> mydb.put('3', '4', txn, 0)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
bsddb.db.DBInvalidArgError: (22, 'Invalid argument -- Transaction
specified for a DB handle opened outside a transaction')

More information about the pybsddb mailing list