从jupyter笔记本连接mysqlserver

66bbxpm5  于 2021-06-18  发布在  Mysql
关注(0)|答案(1)|浏览(644)

我写了这段代码来连接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) .

lsmd5eda

lsmd5eda1#

将“字符替换为”。
新代码如下:
从sqlalchemy导入sqlalchemy导入创建\u引擎
engine=sqlalchemy.create\u engine('mysql+mysqlconnector://root:password@localhost:3306/dbname')

相关问题