On Thu, Dec 13, 2012 at 3:56 PM, Jeff Archer <
jsarc...@nanotronicsimaging.com> wrote:

> I have encountered an error of the database disk image is malformed.
> Database was send in by a customer so I'm not exactly sure how it came to
> be this.  I have found that this can be repaired by SQLiteExpertPro by the
> Database | Repair functionality but have not been able yet to find anything
> in the C API that might be used to implement this functionality.
>
> Could someone please point me to some information on how I might make my
> product be able to recover from this situation.
>


Information on how to corrupt a database file:
http://www.sqlite.org/howtocorrupt.html

There is no general technique for repairing corruption.  I don't know how
SQLiteExpertPro does it.  One thing that sometimes works, at least
partially is to do:

      sqlite3 corrupt.db .dump >out.txt
      # edit out.txt to change "ROLLBACK" on the last line to "COMMIT"
      sqlite3 fixed.db <out.txt

In other words, walk through each table, do a query to extract the content
and print it as text, then feed that text into a new database file.  If you
encounter corruption while doing the initial scan in ascending rowid order,
go back and try again in descending rowid order.  You might not get all of
the content this way, but you should get a lot of it.





>
> SQLite3 version 3.7.13
> Windows 7 x64
>
> Jeff Archer
> Nanotronics Imaging
> jsarc...@nanotronicsimaging.com
> <330>819.4615
> _______________________________________________
> sqlite-users mailing list
> sqlite-users@sqlite.org
> http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
>



-- 
D. Richard Hipp
d...@sqlite.org
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to