Re: [SQLObject] Exception ... ignored (was: should Transaction.commit makeObsolete?)
SQLObject is a Python ORM.
Brought to you by:
ianbicking,
phd
From: Daishi H. <da...@eg...> - 2005-06-23 20:19:53
|
Hi, I'm not sure this is entirely related, but I'm seeing: Exception pysqlite2.dbapi2.ProgrammingError: 'Cannot operate on a=20 closed database.' in <bound method Transaction.__del__ of=20 <sqlobject.dbconnection.Transaction object at 0xb6f9ca2c>> ignored on the attached test code, which goes away if I add a _makeObsolete call in Transaction.commit(). (I'm using the current pysqlite2 and sqlobject). I'm wondering if I'm just not doing the right thing in the test code, or if I should ignore the message, or if there's something actually wrong elsewhere. In particular, is there a better way to obtain the transaction then accessing ._connection as I do? On a separate note, I see that DBConnection has a queryOne() method; is there a corresponding "get_one" method at the SQLObject level that can replace the iter(select()).next() hack in query() below? tia,d --- import sqlobject URI =3D 'sqlite:/:memory:' N =3D 10 class Test(sqlobject.SQLObject): class sqlmeta: cacheValues =3D False _connection =3D sqlobject.connectionForURI(URI) foo =3D sqlobject.StringCol() def create(): Test.dropTable(ifExists=3DTrue) Test.createTable() def load(): transaction =3D Test._connection.transaction() for i in xrange(N): Test(foo=3Dstr(i), connection=3Dtransaction) transaction.commit() def query(): for i in xrange(N): x =3D iter(Test.selectBy(foo=3Dstr(i))).next() #print x def main(): #Test._connection.debug =3D True create() load() query() if __name__ =3D=3D '__main__': main() On Jun 21, 2005, at 6:23 AM, Kevin Dangoor wrote: > In dbconnection.py, the error messages seem to imply that after you've > committed (or rolled back) a transaction, you need to either get a new > transaction object or call begin(). Looking at the code, though, > rollback calls _makeObsolete, whereas commit does not. > > This is causing some interesting behavior in my test code, because I > made some database updates that I hadn't committed and they were > getting rolled back when the previous, already committed transaction > was garbage collected. > > I can certainly add an explicit rollback in my own code, but I wanted > to see if there really should be a makeObsolete call in there. > > Kevin > > > ------------------------------------------------------- > SF.Net email is sponsored by: Discover Easy Linux Migration Strategies > from IBM. Find simple to follow Roadmaps, straightforward articles, > informative Webcasts and more! Get everything you need to get up to > speed, fast. http://ads.osdn.com/?ad_idt77&alloc_id=16492&op=3Dclick > _______________________________________________ > sqlobject-discuss mailing list > sql...@li... > https://lists.sourceforge.net/lists/listinfo/sqlobject-discuss > |