我写了这段代码来连接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)
.
1条答案
按热度按时间lsmd5eda1#
将“字符替换为”。
新代码如下:
从sqlalchemy导入sqlalchemy导入创建\u引擎
engine=sqlalchemy.create\u engine('mysql+mysqlconnector://root:password@localhost:3306/dbname')