1. ModuleNotFoundError: No module named 'mysql'
需要安装链接驱动, 比如
pip install mysqlclient # 或 pip install pymysql # 或 pip install mysql-connector-python
2. pandas的 pd.read_sql(ad_first_query, conn) 报错: execute return self.connectable.execution_options().execute(*args, **kwargs) AttributeError: 'OptionEngine' object has no attribute 'execute'
这里 python为3.10.11 包版本:
SQLAlchemy==2.0.18
pandas==1.5.3 mootdx==0.10.10mysql-connector-python==8.0.33 tdxpy==0.2.3
一般就是pandas版本及语法问题
方式1:退回版本为1.4.1
方式2:如果版本为1.5.3 可以修改语法
from sqlalchemy import create_engine, text db_url = f'mysql+mysqlconnector://{username}:{password}@{ip}:{port}/{database}' engine = create_engine(db_url) pd.read_sql(text(sql_query), engine.connect())之前为 pd.read_sql(sql_query, engine)
标签:engine,python,mysql,报错,sql,pandas From: https://www.cnblogs.com/init-007/p/17544266.html