Reputation: 181
I tried to connect mysql via pyodbc, same code works on python2, but I get an error on python3.
here is my code:
_protocal = 'DRIVER={/usr/local/lib/libmyodbc5.so};SERVER=127.0.0.1;
PORT=3306;DATABASE=learn;UID=root;PASSWORD=root'
conn = pyodbc.connect(_protocal)
cursor = conn.cursor()
test_sql = 'select * from students'
cursor.execute(test_sql)
here is the error message on python3:
Traceback (most recent call last):
File "temp.py", line 82, in <module>
main()
File "temp.py", line 71, in main
cursor.execute(test_sql)
pyodbc.Error: ('HY000', '[HY000] [MySQL][ODBC 5.1 Driver][mysqld-
5.7.18]Querywas empty (1065) (SQLExecDirectW)')
Thanks for help.
Upvotes: 1
Views: 217
Reputation: 123549
The last revision of MySQL Connector/ODBC 5.1 was released over five (5) years ago. Upgrading the driver to the latest GA version (5.3.10) and upgrading iODBC appears to have resolved the issue.
Upvotes: 1