It would seem that at least for some files I've tried, if a file has content but it isn't a SQLite, SQLite (3) will open the file and overwrite whatever was there. Is this the expected behavior? As a workaround, I can look for the header string, but I'd really like it if the SQLite library could tell me whether the file is a legal database or not. Or maybe such a function exists and I just haven't seen it?

If you are on Mac OS X, (or Linux, I would assume), you can do the following to see what I meant:

> echo "this is not a database" > notadatabase.db
> cat notadatabase.db
> sqlite3 notadatabase.db
sqlite> create table foo(a);
sqlite> .exit
> cat notadatabase.db

Reply via email to