Problem with sqlite
Gerhard Häring
gh at ghaering.de
Mon Mar 31 08:39:55 EDT 2008
aiwarrior wrote:
> [...]
> What i'm going to study is whether it's possible to evaluate if a
> table already exists, and if so act accordingly. [...]
You can use a statement like "CREATE TABLE IF NOT EXISTS tbl(col1, col2);".
If you just want to check, you can query SQLite's schema metadata with
something like
def table_exists(con, table_name):
return con.execute("select count(*) from sqlite_master where
type='table' and tbl_name=?", (table_name,)).fetchone()[0]
-- Gerhard
More information about the Python-list
mailing list