Q) On sqlite3_Open(), when the file with given filename doesn't exists, SQLite creates new database. But usually, the application needs to do some initialization work to be able to use this new database (create tables etc.) So, what is the most natural way to determine, that Open() created new database instead of opening the existing one?
A) Use some system API funtion like IsFileExists(DB_filename) before calling sqlite_open(DB_filename)
A) or, use the "user_version" pragma. Right after calling open(), do "pragma user_version". If it returns "0", then assume that this is a new file -- create your tables and do "pragma user_version=1" to mark that you've created your tables in this db. The next time you do "pragma user_version", it will return 1, signifying that you've previously set up this db.
No virus found in this outgoing message.
Checked by AVG Anti-Virus.
Version: 7.0.322 / Virus Database: 266.11.17 - Release Date: 5/25/2005