Re: pysqlite - Checking the existance of a table

2005-06-19 Thread Dave Cook
On 2005-06-17, rh0dium [EMAIL PROTECTED] wrote: 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. sqlite_master has already been mentioned, so I'll point out some useful pragmas (under Pragmas to query the database

Re: pysqlite - Checking the existance of a table

2005-06-18 Thread Cousin Stanley
| 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. rh0dium One way to get at a list of table names in an SQLite data base is to query the sqlite_master table import sys import sqlite this_db =

Re: pysqlite - Checking the existance of a table

2005-06-18 Thread Gerhard Häring
rh0dium wrote: 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

Re: pysqlite - Checking the existance of a table

2005-06-18 Thread Peter Hansen
Gerhard Hring wrote: Or you can query the sqlite_master table (don't know any specification off-hand, but it contains the schema information). Item #9 in the FAQ (http://www.sqlite.org/faq.html#q9) shows it as: CREATE TABLE sqlite_master ( type TEXT, name TEXT, tbl_name TEXT,

Re: pysqlite - Checking the existance of a table

2005-06-17 Thread Matthias Kluwe
Simply use the internal table SQLite_Master: select name from SQLite_Master will return all existing tables. Regards, Matthias -- http://mail.python.org/mailman/listinfo/python-list