[SOLVED] How to check for SQLite database existence? lazarus / 16-Databases ---------------------------------------------------------------------- ocpaul20 · 2015-04-24 23:59 SQLite3 ------- I dont seem to be able to check for database/dataset existence. When the project form starts, the database file is created by the component. However the database file created EMPTY. This means that I cannot check if the file exists, and the program does not fail until I get to dataset open which is too late. What is the correct sequence of checking and method to check if the database and table exist please? In the IDE, I get system exception messages even if I wrap the open in a try/except block. Is there any way of SILENTLY checking for existence in these cases? -------------------------------------------------------------- Puppy Linux Slacko 5.7 Lazarus 1.5 FPC version 2.6.5 Revision 48817 i396-linux-gtk2 ---------------------------------------------------------------------- LacaK · 2015-04-25 07:20 To check for existence of Database you can use:   FileExists('my_sqlite_db.db') To check for existenceof any table inside database you can use f.e. (if you use sqlDB components):   TSQLite3Connection.GetTableNames(SL) which fills TStringList SL with table names and then you can use SL.IndexOf('my_table') to check if given table name exists in list. ---------------------------------------------------------------------- ocpaul20 · 2015-04-25 12:14 Thanks very much for the reply. ---------------------------------------------------------------------- Ocye · 2015-04-26 08:47 Alternatively you can do this Code: [Select]CREATE TABLE IF NOT EXISTS ...since you might want to create it anyway. http://www.sqlite.org/lang_createtable.html