On 16 Oct 2017, at 2:14am, Fiona <cxfhn1...@gmail.com> wrote:

> Thanks a lot! That may be the problem: my db file is corrupted. Below is the
> *PRAGMA integrity_check* result. It didn't return OK. 
> <http://sqlite.1065341.n5.nabble.com/file/t8403/integrity_check.jpg> 
> 
> I think it's because I set PRAGMA synchronous=off in Python code to enhance
> insert speed. 
> Does that mean this db file can not be used anymore?

Yes.  Anything done with this database may give the wrong result.  Any changes 
you make to it may overwrite data you want preserved.  Do not use it any more.  
This is our best method of rescuing as much data as possible:

1) Open the database in the SQLite shell tool.
2) Use the ".dump" command to dump the data into a file of SQL commands:

        .dump sql.txt

3) Quit the SQLite shell tool with the ".quit" command.
4) Using a text editor open the text file and make sure it looks like it has 
the right sort of commands in.
5) Use the SQLite shell tool to create a new database file:

        sqlite newfile.sqlite

6) Use the ".read" command to read and execute the commands from the text file:

        .read sql.txt

7) Quit the SQLite shell tool with the ".quit" command.

You now have a new database which is guaranteed uncorrupt as far as SQLite is 
concerned (the data in it may not be all the data you had originally, some of 
that may have been lost).  You can rename your old and new database files and 
see whether things are working correctly now.

Simon.
_______________________________________________
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to