I am using MySQLdb
in python3.5.2 to connect to mysql. I have done this in many machine and have never faced issues. In a new machine, I have installed
MySQL-5.7.24-0ubuntu0.16.04.1 (Ubuntu) version. And I am using the following code to connect:
import MySQLdb
conn=MySQLdb.connect(host="localhost",user="root", passwd="Abcabc", db="testdb",port=3306)
I am getting the following error:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/ubuntu/.virtualenvs/tfod_api/lib/python3.5/site-packages/MySQLdb/__init__.py", line 80, in Connect
from MySQLdb.connections import Connection
File "/home/ubuntu/.virtualenvs/tfod_api/lib/python3.5/site-packages/MySQLdb/connections.py", line 36
raise errorclass, errorvalue
^
SyntaxError: invalid syntax
I couldn't figure out any syntax error here and the same code is working in many other machines. Shall I uninstall MySQL and try again. This requires me to create multiple tables again. What should I do?