Prev: timer for a function
Next: reconstruct the source of a lambda from its func_code, func_name, etc
From: Gnarlodious on 5 Feb 2010 13:44 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? -- Gnarlie
From: Aahz on 5 Feb 2010 18:08 In article <6cf467a9-99d7-4fda-99da-075b4b38e3e0(a)k6g2000prg.googlegroups.com>, Gnarlodious <gnarlodious(a)gmail.com> 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? Check first -- Aahz (aahz(a)pythoncraft.com) <*> http://www.pythoncraft.com/ import antigravity
From: Roger Binns on 8 Feb 2010 03:11 -----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-----
|
Pages: 1 Prev: timer for a function Next: reconstruct the source of a lambda from its func_code, func_name, etc |