Simple sqlite3 question

John Nagle nagle at
Tue Apr 24 21:20:26 CEST 2007

Jerry Hill wrote:
> On 24 Apr 2007 10:03:45 -0700, cjl <cjlesh at> wrote:
>> When I run the script and there is no file named optiondata, one is
>> created and the correct data is added to it.  If I run the script
>> again then the data from the first run seems to be replaced with the
>> data from the second run. I expected that the data from the second run
>> would be appended to the database file, not replace it.
> It sounds like you're not calling conn.commit() before you close the
> database.  By default sqlite (and any other DBAPI 2.0 compliant sql
> wrapper) will start in transactional mode.  You need to commit() your
> transactions or they will be rolled back when you close the database
> connection.  If you don't want to call commit on your own, you can
> switch the database into autocommit mode by setting the isolation
> level to None when you open the connection, like this:
> conn = sqlite3.connect('.\optiondata', isolation_level=None)

    Don't do that; make the commit calls.  Otherwise you'll be back
here complaining about how bad stuff happened when two copies of
the program ran at the same time.

					John Nagle

More information about the Python-list mailing list