[SQLObject] Re: Transaction semantics do not appear to be working
SQLObject is a Python ORM.
Brought to you by:
ianbicking,
phd
From: Ahmed M. A. <ahm...@wa...> - 2004-06-15 10:52:56
|
Hi, The connection object that you are using is your original connection, the transaction create a new connection,so you must use that one. The Transaction class uses internally this connection.It exposes the same interface than the Connection class itself and uses a delegation mechanism to communicate with the database server.Here's how you can modify your code in order to work with transaction: <begin modified code> trans = WKVTestTable._connection.transaction() for i in xrange(1000): newrec = WKVTestTable(connection=trans,...) --> set the connection argument to be the transaction itself trans.commit() </end modified code> Ahmed MOHAMED ALI "William Volkman" <wkv...@ne...> wrote in message news:108...@ch...... > I've a small program that inserts a couple of thousand rows into > a postgres database. It appears that transaction handling is > not working as I can see intermediate rows in the database > before the program has committed them. I believe that I'm following > the correct sequence of commands: > > conn = connectionForURI("postgres://wkv@localhost/testdb") > class WKVTestTable(SQLObject): > _connection = conn > _table = 'testtable' > > id = IntCol(dbName='testid') > officeid = IntCol(dbName='officeid') > pointid = IntCol(dbName='pointid') > dest = StringCol(length=1, varchar=False, dbName='dest') > origin = StringCol(length=1, varchar=False, dbName='origin') > createdate = DateCol(dbName='createdate', default=func.CURRENT_DATE) > sourcedate = DateCol(dbName='sourcedate', default=None) > > > trans = WKVTestTable._connection.transaction() > > for i in xrange(1000): > newrec = WKVTestTable(...) > trans.commit() > > I did not specify _cacheValues=False as that would seem to only > apply to a multi access environment (perhaps I'm mistaken?) > > I've updated to revision 126 just now and still no joy. Is > autocommit being set on the connection? Postgresql V7.3.4 on > RH 9, psycopg-1.1.11-py2.2_RH9_wkv1 > > Any suggestions? > > Thanks, > William. > > > > > ------------------------------------------------------- > This SF.Net email is sponsored by the new InstallShield X. > From Windows to Linux, servers to mobile, InstallShield X is the > one installation-authoring solution that does it all. Learn more and > evaluate today! http://www.installshield.com/Dev2Dev/0504 |