gpt4 book ai didi

mysql - mysql数据库如何连接superset?

转载 作者:行者123 更新时间:2023-12-05 09:10:41 30 4
gpt4 key购买 nike

我尝试使用此 SQLAlchemy URI 将超集与 mysql 数据库连接:mysql://localhost:3306/mysql/database/table1 但无法连接。

我遇到了这个错误:

ERROR: {"error": "Connection failed!

The error message returned was:
No module named 'MySQLdb'", "stacktrace": "Traceback (most recent call last):
File \"/Users/akay/venv/lib/python3.7/site-packages/superset/views/core.py\", line 1703, in testconn
engine = database.get_sqla_engine(user_name=username)
File \"/Users/akay/venv/lib/python3.7/site-packages/superset/utils/core.py\", line 131, in __call__
value = self.func(*args, **kwargs)
File \"/Users/akay/venv/lib/python3.7/site-packages/superset/models/core.py\", line 923, in get_sqla_engine
return create_engine(url, **params)
File \"/Users/akay/venv/lib/python3.7/site-packages/sqlalchemy/engine/__init__.py\", line 479, in create_engine
return strategy.create(*args, **kwargs)
File \"/Users/akay/venv/lib/python3.7/site-packages/sqlalchemy/engine/strategies.py\", line 87, in create
dbapi = dialect_cls.dbapi(**dbapi_args)
File \"/Users/arkay/venv/lib/python3.7/site-packages/sqlalchemy/dialects/mysql/mysqldb.py\", line 118, in dbapi
return __import__(\"MySQLdb\")
ModuleNotFoundError: No module named 'MySQLdb'
"}

有什么方法可以连接到 MySQL 数据库吗?

最佳答案

MySQLdb 不兼容 Python 3,你需要使用 pymysql。

安装pymysql:

$ pip install pymysql

使用以下 URI 字符串连接到 mysql 数据源。

mysql+pymysql://user:pass@host/databasename

关于mysql - mysql数据库如何连接superset?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61222772/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com