INSERT statements not INSERTING when using mysql from python
Tim Roberts
timr at probo.com
Sat Dec 30 03:02:20 EST 2006
"Ben" <Benjamin.Barker at gmail.com> wrote:
>Perhaps when I'm checking for table existance using mysql through
>python I have to be more explicit:
>
>Where I did have:
>USE database;
>IF NOT EXISTS CREATE table(.....
>
>Perhaps I need:
>USE database;
>IF NOT EXISTS CREATE database.table(.....
>
>I'll try it after lunch. Does anyoone know whether this might be the
>problem?
The "IF NOT EXISTS" clauses are not standard SQL; they are MySQL
extensions. Although my reasons are nebulous and more related to principle
than to practicality, I try never to use them, because they might not be
available in my next database.
After all, you should have a pretty good idea at any given time whether
your database and table already exist.
I do occasionally allow myself a "DROP TABLE IF NOT EXISTS", which then
allows the unadulterated "CREATE TABLE" command.
--
Tim Roberts, timr at probo.com
Providenza & Boekelheide, Inc.
More information about the Python-list
mailing list