我编写了这段代码,以从Jupyter笔记本连接MySQLServer:
import sqlalchemy
from sqlalchemy import create_engine
engine = sqlalchemy.create_engine(‘mysql+mysqlconnector://root:password@localhost:3306/dbname′)
我遇到以下错误:
File "<ipython-input-12-c958f7670e02>", line 6
engine = sqlalchemy.create_engine(‘mysql+mysqlconnector://root:password@localhost:3306/events′)
^
SyntaxError: invalid character in identifier
pip list
命令还会列出PyMySQL (0.9.2)
。
答案 0 :(得分:-1)
将“字符”替换为“”。
这是新代码:
导入sqlalchemy 从sqlalchemy导入create_engine
engine = sqlalchemy.create_engine('mysql + mysqlconnector:// root:password @ localhost:3306 / dbname')