Re: [SQLObject] autoCommit broken with PostgreSQL?
SQLObject is a Python ORM.
Brought to you by:
ianbicking,
phd
From: Igor M. <dow...@gm...> - 2005-12-30 14:42:18
|
Here are the model and the short test program: class System(SQLObject): _cacheValue =3D False class sqlmeta: table =3D'ships.systems' idName =3D'system_id' name =3D StringCol(dbName=3D"system_name",alternateID=3DTrue,notNon= e=3DTrue) =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D [iseegc@www iseegc]$ tg-admin shell Python 2.4.1 (#1, Dec 4 2005, 16:28:22) Type "copyright", "credits" or "license" for more information. In [1]: System(name=3D"Hyperdrive") #notice the id of 4 Out[1]: <System 4L name=3D'Hyperdrive'> In [2]: System._connection.autoCommit #notice auto commit is true Out[2]: True In [3]: # CTRL-D to quit ipython [iseegc@www iseegc]$ tg-admin shell Python 2.4.1 (#1, Dec 4 2005, 16:28:22) Type "copyright", "credits" or "license" for more information. In [1]: System.get(4) --------------------------------------------------------------------------- sqlobject.main.SQLObjectNotFound Traceback (most recent call last) /home/iseegc/iseegc/<console> /usr/lib/python2.4/site-packages/SQLObject-0.7.0-py2.4.egg/sqlobject/main.p= y in get(cls, id, connection, selectResults) 906 val =3D cls(_SO_fetch_no_create=3D1) 907 val._SO_validatorState =3D SQLObjectState(val) --> 908 val._init(id, connection, selectResults) 909 cache.put(id, cls, val) 910 finally: /usr/lib/python2.4/site-packages/SQLObject-0.7.0-py2.4.egg/sqlobject/main.p= y in _init(self, id, connection, selectResults) 944 selectResults =3D self._connection._SO_selectOne(self, dbNames) 945 if not selectResults: --> 946 raise SQLObjectNotFound, "The object %s by the ID %= s does not exist" % (self.__class__.__name__, self.id) 947 self._SO_selectInit(selectResults) 948 self._SO_createValues =3D {} SQLObjectNotFound: The object System by the ID 4 does not exist In [2]: [i for i in System.select()] #as you can see, we added "Hyperdrive" but it wasn't committed Out[2]: [<System 2 name=3D'Gravity Well'>] In [3]: System(name =3D "Hyperdrive") #lets try to add it again Out[3]: <System 5L name=3D'Hyperdrive'> In [4]: System._connection.commit() In [5]: #now I hit CTRL+D to quit interpreter [iseegc@www iseegc]$ tg-admin shell Python 2.4.1 (#1, Dec 4 2005, 16:28:22) Type "copyright", "credits" or "license" for more information. In [1]: System.get(5) #aha, now it works because it was committed Out[1]: <System 5 name=3D'Hyperdrive'> In [2]: =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D So even though autoCommit is on, it doesn't commit anything. -Igor p.s. using sqlobject 0.7.0 py2.4 egg On 12/30/05, Oleg Broytmann <ph...@ma...> wrote: > > On Fri, Dec 30, 2005 at 12:48:22AM -0600, Igor Murashkin wrote: > > I'm using PostgreSQL 8.0, and even when I turn off caching by adding > > _cacheValue =3D False to my model, it still won't commit automatically.= If > I > > don't explicitly call commit() or rollback() I will just end up with an > > error. I am using sqlobject 7.0, I was wondering if autoCommit is > broken? > > Please show a short test program and the error... > > Oleg. > -- > Oleg Broytmann http://phd.pp.ru/ ph...@ph... > Programmers don't die, they just GOSUB without RETURN. > > > ------------------------------------------------------- > This SF.net email is sponsored by: Splunk Inc. Do you grep through log > files > for problems? Stop! Download the new AJAX search engine that makes > searching your log files as easy as surfing the web. DOWNLOAD SPLUNK! > http://ads.osdn.com/?ad_id=3D7637&alloc_id=3D16865&op=3Dclick > _______________________________________________ > sqlobject-discuss mailing list > sql...@li... > https://lists.sourceforge.net/lists/listinfo/sqlobject-discuss > |