Reputation: 11
I found a function that will help me load a disk SQLite database to a memory database, but have found that the module I need, apsw, doesn't support it, while pysqlite does. I need apsw because it has most of the functions I need that pysqlite does not. Is there any work around to completely copying to a database?
Upvotes: 1
Views: 944
Reputation: 3348
As singularity pointed out, APSW provides the backup functionality builtin to SQLite.
The reason you can't continue to use cursors (in practise the underlying SQLite compiled statements) is because the database schema has potentially completed changed as you have overwritten it with a backup. You can use close methods to force items closed.
For some reason many developers seem to treat cursors as a precious commodity and attempt to reuse them and keep them around at every opportunity. Cursors themselves are very lightweight, just slightly more "heavy" than a Python integer. The underlying SQLite compiled statements are more heavyweight but at the Python object level they are switch around for each statement executed. (ie an APSW cursor points to the currently executing SQLite compiled statement.)
BTW APSW also includes the ability to dump the database. You can use the shell class to do the work for you.
http://apidoc.apsw.googlecode.com/hg/shell.html#shell-class
Disclosure: I am the APSW author.
Upvotes: 2