Can sqlite read gzipped databases?

Discussion in 'Python' started by Paul Smith, Mar 21, 2007.

  1. Paul Smith

    Paul Smith Guest

    Hi,

    I'd like to read a series of sqlite database files that have already been
    gzipped and was wondering if this can be done on the fly. In other words, can
    I avoid explicitly unzipping the file into another file, but instead get an
    SQL connection to the zip file either directly (can't see an option to do
    this) or to an object in memory resulting from unzipping, eg. (hypothetically);

    import gzip
    from sqlite3 import dbapi2 as sqlite

    data = gzip.GzipFile('Mydbase.db.gz','r')
    d = data.read()
    cnx = sqlite.connect(d) # or .connect(data)
    cur = cnx.cursor()
    .....etc

    The above of course doesn't work, but just to give you the idea.

    Thanks,
    Paul
     
    Paul Smith, Mar 21, 2007
    #1
    1. Advertising

  2. Paul Smith

    John Nagle Guest

    Gzipped files aren't a good random access medium. It's
    unlikely that anyone will implement this.

    John Nagle

    Paul Smith wrote:
    > Hi,
    >
    > I'd like to read a series of sqlite database files that have already been
    > gzipped and was wondering if this can be done on the fly. In other words, can
    > I avoid explicitly unzipping the file into another file, but instead get an
    > SQL connection to the zip file either directly (can't see an option to do
    > this) or to an object in memory resulting from unzipping, eg. (hypothetically);
    >
    > import gzip
    > from sqlite3 import dbapi2 as sqlite
    >
    > data = gzip.GzipFile('Mydbase.db.gz','r')
    > d = data.read()
    > cnx = sqlite.connect(d) # or .connect(data)
    > cur = cnx.cursor()
    > ....etc
    >
    > The above of course doesn't work, but just to give you the idea.
    >
    > Thanks,
    > Paul
    >
    >
     
    John Nagle, Mar 21, 2007
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Ken North
    Replies:
    0
    Views:
    606
    Ken North
    Jul 14, 2005
  2. John Nagle
    Replies:
    1
    Views:
    592
    Martin v. Löwis
    Nov 22, 2007
  3. Helmut Jarausch
    Replies:
    4
    Views:
    6,481
    Ethan Furman
    Jul 15, 2009
  4. DmitryB
    Replies:
    2
    Views:
    375
    Michele Dondi
    Jun 1, 2007
  5. Replies:
    0
    Views:
    974
Loading...

Share This Page