无法使用 ipython-sql 从 Jupyter Lab 连接到 MySQL

问题描述 投票:0回答:0

我在 Docker 容器中运行 MySQL,在我的 jupyter 实验室中,我有以下单元格:

# Importing module
import mysql.connector

# Creating connection object
mydb = mysql.connector.connect(
    host = "localhost",
    port = 3307,
    user = "bob",
    password = "1234",
    database = 'testDB'
)

# Printing the connection object
print(mydb)

哪个打印: <mysql.connector.connection_cext.CMySQLConnection object at 0x7fc633769dd0>

但是我想使用 ipython-sql 连接,所以我使用 %load_ext sql 加载扩展,但是当我尝试时:

%sql mysql://bob:1234@localhost:3307/testDB

我得到错误:

Connection info needed in SQLAlchemy format, example:
               postgresql://username:password@hostname/dbname
               or an existing connection: dict_keys([])
No module named 'MySQLdb'
Connection info needed in SQLAlchemy format, example:
               postgresql://username:password@hostname/dbname
               or an existing connection: dict_keys([])
jupyter-lab mysql-connector ipython-sql
© www.soinside.com 2019 - 2024. All rights reserved.