0

What's the easiest way to backup/restore sqlite memory database to file database in Qt.

1
  • 2
    Why not use a plain file database to start with? Commented Jan 4, 2012 at 13:27

1 Answer 1

1

I think you will need to work with SQLite directly to do this. SQLite has an Online Backup API, the first example is backing up an in-memory database to a file database, so it should be possible to do what you need to do.

To get a sqlite3* database handle, get the driver (QSqlDatabase::driver) from the database then get the handle (QSqlDriver::handle). The example code in the Qt docs shows how to cast the QVariant into a sqlite3* handle.

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

4 Comments

I think this way is not native enough. Because by using this, I should add sqlite3.c and sqlite3.h into project,when Qt already complies these two files into library. Isn't it make the program file large and bad by adding the same code into one file.
If you are using dynamic libraries, then you only need to include sqlite3.h and link against sqlite3.
Can you tell me how to link against sqlite3 without using sqlite3.dll
You can either statically compile sqlite into your program by compiling in sqlite3.c, or dynamically link against sqlite3.dll, the code needs to be somewhere! The other option would be to link against the qtsql_sqlite driver, but that would only work if the sqlite symbols were exposed by the driver DLL (check using Dependency Walker ).

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.