Re: SQLite3 trapping OperationalError

2007-03-10 Thread paul
jim-on-linux schrieb:
 pyhelp,
 
 I set up a table in SQLite3.
 
 While running other modules I want to know if a  
 table exists.
 
 SQL has a command List Tables but I don't think 
 SQLlite3 has this command.
I think list tables is a mysqlism

 
 I've tried 
cursor.execute(select * from debtor where key
 is not null )
FROM sqlite_master SELECT name WHERE type='table';

cheers
 Paul

-- 
http://mail.python.org/mailman/listinfo/python-list


SQLite3 trapping OperationalError

2007-03-09 Thread jim-on-linux
pyhelp,

I set up a table in SQLite3.

While running other modules I want to know if a  
table exists.

SQL has a command List Tables but I don't think 
SQLlite3 has this command.

I've tried 
   cursor.execute(select * from debtor where key
is not null )

The table debtor does not exist so I get 
OperationalError
which I want to trap with try/except or some other 
way.

However python 2.5, 
except OperationalError: 
responds with 
OperationalError is not defined.

Ideas on how to determine if a table exists would 
be welcome.

jim-on-linux


-- 
http://mail.python.org/mailman/listinfo/python-list


Re: SQLite3 trapping OperationalError

2007-03-09 Thread Jerry Hill
On 3/9/07, jim-on-linux [EMAIL PROTECTED] wrote:
 However python 2.5,
 except OperationalError:
 responds with
 OperationalError is not defined.

I believe that needs to be spelled
except sqlite3.OperationalError:
do_something()

-- 
Jerry
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: SQLite3 trapping OperationalError

2007-03-09 Thread jim-on-linux
On Friday 09 March 2007 13:10, Jerry Hill wrote:
 On 3/9/07, jim-on-linux [EMAIL PROTECTED] 
wrote:
  However python 2.5,
  except OperationalError:
  responds with
  OperationalError is not defined.

 I believe that needs to be spelled
 except sqlite3.OperationalError:
 do_something()

 --
 Jerry

Thanks,
 except sqlite3.OperationalError:
works for me.

jim-on-linux
-- 
http://mail.python.org/mailman/listinfo/python-list