Nick Shaw <nick.s...@citysync.co.uk> wrote:
> Is there a reason that sqlite3_open() will happily "open" a non-sqlite
> file, returning SQLITE_OK, instead of returning SQLITE_NOTADB, which
> would seem a more obvious return value?

SQLite doesn't actually touch the file until the first "substantive" statement 
is executed on the connection. This allows one to set various PRAGMAs that can 
only be set before the database is created.

> It will also happily open a
> sqlite database that it will later say is corrupt when I try to query
> some data, implying it doesn't do data integrity checks on the database
> on opening?

Do you really want SQLite to scan a gigabytes-large file every time it's opened?

> So... Assuming the above is how sqlite is meant to work, what would be
> the best way to ascertain if a successfully opened file is ok to use?

Run "PRAGMA integrity_check" right after opening.
-- 
Igor Tandetnik

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

Reply via email to