FAQ
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?

Thanks,
Paul.

Search Discussions

  • Joshua Kugler at Jul 6, 2009 at 8:45 pm

    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.

    j
  • Paul Moore at Jul 6, 2009 at 10:50 pm

    2009/7/6 Joshua Kugler <joshua at joshuakugler.com>:
    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.
    Paul.
  • Roger Binns at Jul 7, 2009 at 6:16 am

    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
  • Joshua Kugler at Jul 7, 2009 at 9:07 pm

    Roger Binns wrote:
    Joshua Kugler wrote:
    BTW, APSW is written by the same author as pysqlite.
    Not even remotely true :-)
    Sorry about that...since pysqlite and APSW are both discusses on the
    pysqlite list, I had made an incorrect assumption. Oops.

    j
  • Joshua Kugler at Jul 9, 2009 at 5:17 pm

    Joshua Kugler wrote:
    Sorry about that...since pysqlite and APSW are both discusses on the
    pysqlite list, I had made an incorrect assumption. Oops.
    "are both discusses?" Yeef, I must have been out of it. Discussed, thank
    you. :)

    j
  • Aahz at Jul 10, 2009 at 2:00 am
    In article <mailman.2905.1247159861.8015.python-list at python.org>,
    Joshua Kugler wrote:
    Joshua Kugler wrote:
    Sorry about that...since pysqlite and APSW are both discusses on the
    pysqlite list, I had made an incorrect assumption. Oops.
    "are both discusses?" Yeef, I must have been out of it. Discussed, thank
    you. :)
    Who's Yeef? ;-)
    --
    Aahz (aahz at pythoncraft.com) <*> http://www.pythoncraft.com/

    "as long as we like the same operating system, things are cool." --piranha

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouppython-list @
categoriespython
postedJul 6, '09 at 12:05p
activeJul 10, '09 at 2:00a
posts7
users4
websitepython.org

People

Translate

site design / logo © 2022 Grokbase