Using the MySQLdb module

Michael Mayhew mayhew at cis.ohio-state.edu
Wed Apr 23 15:19:58 EDT 2003


Greetings,

	I am trying to use the MySQLdb module on a simple database local to my 
personal Linux machine. However, I keep running into trouble when I 
execute SQL on my cursor objects, specifically when I execute the insert 
command. I have been through numerous docs on the Python DB API v2.0 and 
on the module itself but have not turned up anything useful. Any 
assistance would be greatly appreciated. Here is the error message:



Traceback (most recent call last):
   File "<stdin>", line 1, in ?
   File "/usr/lib/python2.2/site-packages/MySQLdb/cursors.py", line 95, 
in execute
     return self._execute(query, args)
   File "/usr/lib/python2.2/site-packages/MySQLdb/cursors.py", line 114, 
in _execute
     self.errorhandler(self, exc, value)
   File "/usr/lib/python2.2/site-packages/MySQLdb/connections.py", line 
33, in defaulterrorhandler
     raise errorclass, errorvalue
_mysql_exceptions.OperationalError: (1054, "Unknown column 'atr' in 
'field list'")



It seems that the values I am passing in my cursor.execute(SQL) 
statement are actually not being parsed as values but rather as column 
headings. I have tried many different forms of the SQL and keep 
producing the same error message. Here also is a sample structure of the 
SQL command, where c is the cursor object:



sql = "insert into refFlatHum values ( %s, %s, %d, %d )" % ('atr', 
'chr1', 90810, 92190)

c.execute(sql)



TIA, Michael Mayhew





More information about the Python-list mailing list