I have a script that connects to MySQL and executes an SQL script to load the data into Excel. Everything works fine until I put this one line in the SQL:
convert_tz(from_unixtime(o.DeviceTimeStamp/1000, '%Y-%m-%d %H:%i:%s'), 'UTC', 'America/New_York')
What I'm doing is pulling back a unix time stamp and converting it to eastern time, as requested by the customer. I know the unix time stamp is not the normal version and I've accounted for that. When I run the same query directly in MySQL it works perfectly. When I run it using Python it get this error:
Traceback (most recent call last): File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/mysql/connector/cursor.py", line 78, in call return bytes(self.params[index]) IndexError: tuple index out of range
During handling of the above exception, another exception occurred:
Traceback (most recent call last): File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/pandas/io/sql.py", line 1409, in execute cur.execute(*args) File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/mysql/connector/cursor.py", line 550, in execute stmt = RE_PY_PARAM.sub(psub, stmt) File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/mysql/connector/cursor.py", line 81, in call "Not enough parameters for the SQL statement") mysql.connector.errors.ProgrammingError: Not enough parameters for the SQL statement
If I take that line out, the query and the script work just fine. Any idea why that line causes an error?