1

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?

2 Answers 2

2

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.

Sign up to request clarification or add additional context in comments.

Comments

0

Check the connection.backup() function

1 Comment

Any way to do this without having to delete all curser objects attached to the database?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.