rh0dium said:
Hi all,
I am starting to play with pysqlite, and would like to know if there is
a function to determine if a table exists or not.
You can try to access the table in a try-catch block, something like:
cur.execute("select * from tablename where 1=2")
and check if it fails.
Or you can query the sqlite_master table (don't know any specification
off-hand, but it contains the schema information).
Instead of doing a select on sqlite_master, you can use "pragma
table_info", which returns information for each column in the table,
and, apparently, an empty list if the table does not exist:
[(0, u'bar', u'integer', 0, None, 0)]
[]
HTH,
-- Gerhard