Hello, I am using python to run mysql commands, however I don't think that should be a problem. When I am trying to select vales from a mysql talbe, I am having some trouble with the where clause. The vales DATETIME are all integer values around 38947. When I use the actual value 38947 it selects all 26 rows perfectly. however if I use a variable like thedate=38947, and then use the 'thedate' to select the values form the table, I get an error. really any help would be greatly appreciated, THANK YOU!
Code:
>>> c.execute('Select REF_LEVERAGE from Actual_Daily_Report Where DATETIME=38947')
26L
>>>
>>> thedate=38947
>>> c.execute('Select REF_LEVERAGE from Actual_Daily_Report Where DATETIME=thedate')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/pymodules/python2.6/MySQLdb/cursors.py", line 166, in execute
self.errorhandler(self, exc, value)
File "/usr/lib/pymodules/python2.6/MySQLdb/connections.py", line 35, in defaulterrorhandler
raise errorclass, errorvalue
_mysql_exceptions.OperationalError: (1054, "Unknown column 'thedate' in 'where clause'")
Comment