MySQL Forums
Forum List  »  Connector/Python

1064 error on validated SQL
Posted by: Adrian Nye
Date: December 17, 2008 12:01PM

I'm running this script on MySQL 5.1. I get a 1064 error even though the SQL validates and I have remembered to quote the reserved word that happens to be a column name. The following is the script and then the error Traceback. What could be going on?

import MySQLdb
import sys

if __name__ == '__main__':
try:
conn = MySQLdb.connect (host = "localhost",
user = "root",
passwd = "copters",
db = "birdlist")
except MySQLdb.Error, e:
print "Error %d: %s" % (e.args[0], e.args[1])
sys.exit (1)

cursor = conn.cursor ()

cursor.execute ("""
INSERT INTO lister_species (common_name, scientific_name, "order", ranges, family, scientific_family)
VALUES
('Ostrich', 'Struthio camelus', 'ststss', 'Struthioniformes', 'Ostrich', 'Struthionidae')
""")

cursor.close ()
conn.close ()

>>> ================================ RESTART ================================
>>>

Traceback (most recent call last):
File "C:\Documents and Settings\...\My Documents\BirdList\dbtest.py", line 20, in <module>
""")
File "C:\Python25\Lib\site-packages\MySQLdb\cursors.py", line 166, in execute
self.errorhandler(self, exc, value)
File "C:\Python25\Lib\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 \'"order", ranges, family, scientific_family)\n VALUES\n (\'Ostrich\', \'\' at line 1')

Options: ReplyQuote


Subject
Written By
Posted
1064 error on validated SQL
December 17, 2008 12:01PM
December 17, 2008 12:22PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.