Drop Table w/ MySQLdb?

Victor Subervi victorsubervi at gmail.com
Sun Jun 6 11:07:25 EDT 2010


Hi;
I tried this:

    cursor.execute('drop table tmp%s', tmpTable)

and got this error:

Traceback (most recent call last):
  File "/var/www/html/angrynates.com/cart/cart.py", line 196, in ?
    cart()
  File "/var/www/html/angrynates.com/cart/cart.py", line 189, in cart
    cursor.execute('drop table tmp%s', tmpTable)
  File "/usr/lib64/python2.4/site-packages/MySQLdb/cursors.py", line 163, in
execute
    self.errorhandler(self, exc, value)
  File "/usr/lib64/python2.4/site-packages/MySQLdb/connections.py", line 35,
in defaulterrorhandler
    raise errorclass, errorvalue
ProgrammingError: (1064, "You have an error in your SQL syntax; check the
manual that corresponds to your MySQL server version for the right syntax to
use near ''127541158007'' at line 1")

But when I print that statement out (exchanging the comma for a %) and
manually enter it:

mysql> drop table tmp127541158007;
Query OK, 0 rows affected (0.00 sec)

I am able to successfully drop the table. Why?
TIA,
beno
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20100606/473b2069/attachment.html>


More information about the Python-list mailing list