从Jupyter Notebook连接MySQLServer

时间:2018-09-24 18:26:35

标签: python mysql jupyter-notebook

我编写了这段代码,以从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

enter image description here

pip list命令还会列出PyMySQL (0.9.2)

1 个答案:

答案 0 :(得分:-1)

将“字符”替换为“”。

这是新代码:

导入sqlalchemy 从sqlalchemy导入create_engine

engine = sqlalchemy.create_engine('mysql + mysqlconnector:// root:password @ localhost:3306 / dbname')