-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Gnarlodious wrote:
> Every time I say something like:
> 
> connection=sqlite3.connect(file)
> 
> sqlite creates a new database file. Can this behavior be suppressed
> through SQLite? Or am I forced to check for the file existing first?

This is due to the API that pysqlite uses to talk to SQLite.  (There is a
more recent API but pysqlite remains backwards compatible with older SQLite
versions).

Note that although SQLite will create the file, it will be zero length (*)
until you do a command that causes a database change.

Also as a guideline be careful with SQLite files.  In particular not only is
there a database file, but there may also be a journal file.  If the journal
is removed then the main database file can be corrupted.  (The journal
contains data in order to rollback back incomplete transactions from the
database.)

(*) On Mac due to an operating system bug the file will actually be created
as one byte in length containing the upper case letter 'S'.

There is a dedicated mailing list for Python and SQLite:

  http://groups.google.com/group/python-sqlite

You can use the newer SQLite database open API as well as many other SQLite
APIs not supported by pysqlite by using APSW.  (Disclaimer: I am the author
of APSW.)

Roger
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAktvxyoACgkQmOOfHg372QQjqwCglx0u6OgGgOsQm0Bwd7s6BmCS
7EgAoKDdMZyDaw3Ov+Uqzs3RFX/NSHEK
=/E0N
-----END PGP SIGNATURE-----

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to