目前,Apache Superset 0.37.0 已经支持 MySQL 8。下面是使用 SQLAlchemy 连接 MySQL 8 数据库的示例代码:
from sqlalchemy import create_engine
# replace username, password and hostname with your MySQL 8 server credentials
engine = create_engine('mysql+pymysql://username:password@hostname:3306/database')
# test the connection
with engine.connect() as connection:
result = connection.execute('SELECT 1')
print(result.scalar())
请注意,在使用 MySQL 8 时,需要使用适当的 驱动程序库(例如 PyMySQL) 以确保兼容性。