views:

543

answers:

3

I'm using an SQLite database from python (with SQLAlchemy). For performance reasons, I'd like to populate an in-memory database in the application, and then back up that database to disk.

SQLite has a backup API, which seems would do this transparently.

The APSW documentation says that it wraps the backup API, but I'd like to access this functionality from Python's standard sqlite3 module, or in the best case from SQLAlchemy. Is this possible?

+1  A: 

When I do the following

import sqlite3
dir(sqlite3)

I see none of the backup API methods.

Therefore, the answer is no; you cannot access the API from the sqlite3 module. It appears that no one implemented it.

S.Lott
+2  A: 

the APSW dialect can be added to SQLAlchemy pretty easily as well. It would be very easy to achieve in 0.6, which allows multiple kinds of DBAPI adapters to make use of a common dialect for the database in use.

zzzeek
This sounds very promising, thanks! Can you recommend any place to research this?
Ryan Ginstrom
+2  A: 

If pysqlite and apsw are linked against the same sqlite library then pysqlite can accept apsw connections. See:

http://docs.pysqlite.googlecode.com/hg/sqlite3.html#combining-apsw-and-pysqlite

I will try to do work on this (and other) approaches to getting apsw to work with SQLAlchemy as they are a very useful combination.

Paul Harrington
I was able to use such apsw opened connection with python sqlite3 in sqlalchemy.
iny