Opening a SQLite database in readonly mode

Paul Moore p.f.moore at
Mon Jul 6 18:50:08 EDT 2009

2009/7/6 Joshua Kugler <joshua at>:
> Paul Moore wrote:
>> The SQLite documentation mentions a flag, SQLITE_OPEN_READONLY, to
>> open a database read only. I can't find any equivalent documented in
>> the Python standard library documentation for the sqlite3 module (or,
>> for that matter, on the pysqlite library's website).
>> Is it possible to open a sqlite database in readonly mode, in Python?
> 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.

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.

More information about the Python-list mailing list