How do I, reliably, check in SQLite, whether a particular user table exists?
I am not asking for unreliable ways like checking if a "select *" on the table returned an error or not (is this even a good idea?).
The reason is like this:
In my program, I need to create and then populate some tables if they do not exist already.
If they do already exist, I need to update some tables.
Should I take some other path instead to signal that the tables in question have already been created - say for example, by creating/putting/setting a certain flag in my program initialization/settings file on disk or something?
Or does my approach make sense?
sqlite3.OperationalError
, so you have to parse the error message in order to make sure it's e.g. "table TABLE_NAME already exists" message when you create a table, and if not, reraise the error and I think there's no guarantee the phrasing of the error won't change. – Markus von Broady