Is it possible to open a sqlite database in readonly mode, in Python?
Thanks,
Paul.
Yes, but most likely not with pysqlite. The python sqlite3 module in the
standard library, and the pysqlite module are both DB-API compliant, which
means they probably do not have a method to open the DB read only (as that
is usually enforced at the user permission level).
If you want to use that flag, take a look at APSW. It is a very thin layer
on top of the SQLite C API, and thus supports everything that the C API
supports. It is not, however, DB API compliant, but is very close so not
hard to pick up.
BTW, APSW is written by the same author as pysqlite.
j
Excellent, thanks. I'll have to think whether I want the extra
dependency but at least I know it's possible now.
Thanks for the pointer.
Paul.
Joshua Kugler wrote:
> BTW, APSW is written by the same author as pysqlite.
Not even remotely true :-) pysqlite was written by various people, with
the maintainer of the last several years being Gerhard H�ring. I am the
(sole) author of APSW and have not contributed any code to pysqlite
although ideas have flowed freely between the projects and we share a
mailing list.
I started APSW in late 2004 because I wanted to use SQLite from Python
rather than using a layer that pretended SQLite was like other
databases. There were various quirks of pysqlite I also didn't like
(many since corrected) and so scratched my itch.
If you are just doing simple queries then there isn't much apparent
difference. If you want to be a "power user" of SQLite then APSW is for
you. SQLite has many cool features such as virtual tables (you provide
the underlying data for the SQL queries to work on) and VFS (you provide
the file access). See this link for more details:
http://apsw.googlecode.com/svn/publish/pysqlite.html
Roger
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)
iEYEARECAAYFAkpS6CUACgkQmOOfHg372QS0/gCgiHD9ukUlQYJGCIMWb9hNMLCM
Y/cAnid4dAeFHIdLBmKzGsXrvANkvhR5
=U0wg
-----END PGP SIGNATURE-----
Sorry about that...since pysqlite and APSW are both discusses on the
pysqlite list, I had made an incorrect assumption. Oops.
j
"are both discusses?" Yeef, I must have been out of it. Discussed, thank
you. :)
j
Who's Yeef? ;-)
--
Aahz (aa...@pythoncraft.com) <*> http://www.pythoncraft.com/
"as long as we like the same operating system, things are cool." --piranha