Thread: [SQLObject] MySQL Doesn't Commit
SQLObject is a Python ORM.
Brought to you by:
ianbicking,
phd
From: Alex Le D. <al...@ps...> - 2005-09-29 07:24:00
|
Hi List, I am using the following code to talk to MySQL from sqlobject 0.6.1. The code works fine, but the records are not 'stored' permanently. They appear in the database, but are removed. When the python idle window is closed, the records disappear from the database (alternatively using the .close() method also clears the database). I thought that autoCommit=True would mean that the records are written immediately? How do I close the connection and explicitly force a commit? Working with SQLObject and SQLite doesn't seem to exhibit the same problem. cheers, Alex. from sqlobject import * __connection__ = MySQLConnection(host='localhost', db='test', user='test', passwd='testpass', autoCommit=True) class Stock (SQLObject) : dbStockCode = StringCol() dbShortDescription = StringCol() dbDescription = StringCol() if __name__ == '__main__' : f = open('stock.csv', 'r') lines = f.readlines() f.close() for i, aline in enumerate(lines) : line = aline.rstrip('\r\n') fields = line.split(',') Stock(dbStockCode = fields[0], dbShortDescription = fields[1], dbDescription = fields[2]) # Using the close just gets rid of the records. __connection__.close() -- |
From: Oleg B. <ph...@ma...> - 2005-09-29 07:30:14
|
On Thu, Sep 29, 2005 at 03:21:56PM +0800, Alex Le Dain wrote: > When the python idle window is closed, the records disappear from the > database (alternatively using the .close() method also clears the > database). I thought that autoCommit=True would mean that the records > are written immediately? The problem has been discussed many times before: http://www.google.com/search?q=sqlobject+mysql+autocommit BTW, we've just released version 0.7 rc1. Oleg. -- Oleg Broytmann http://phd.pp.ru/ ph...@ph... Programmers don't die, they just GOSUB without RETURN. |
From: Alex Le D. <al...@ps...> - 2005-09-30 01:04:53
|
Oleg Broytmann wrote: >>When the python idle window is closed, the records disappear from the >>database (alternatively using the .close() method also clears the >>database). I thought that autoCommit=True would mean that the records >>are written immediately? > The problem has been discussed many times before: > > http://www.google.com/search?q=sqlobject+mysql+autocommit I located your post here: http://article.gmane.org/gmane.comp.python.sqlobject/3706 However, you seem to imply that the solution is to enable autocommit or explicitly commit. My problem is that autocommit is enabled. >>__connection__ = MySQLConnection(host='localhost', >> db='test', >> user='test', >> passwd='testpass', >> autoCommit=True) And how do you do an explicit commit, since __connection__.commit() is not defined? > BTW, we've just released version 0.7 rc1. Terrific, I'll give that a try too. Thanks for your help. cheers, Alex. -- |
From: Oleg B. <ph...@ma...> - 2005-09-30 09:11:12
|
On Fri, Sep 30, 2005 at 09:03:45AM +0800, Alex Le Dain wrote: > > BTW, we've just released version 0.7 rc1. > > Terrific, I'll give that a try too. This, I think, is the only way to fix your problem. Oleg. -- Oleg Broytmann http://phd.pp.ru/ ph...@ph... Programmers don't die, they just GOSUB without RETURN. |