【发布时间】:2020-04-15 23:28:46
【问题描述】:
我正在将 pandas 数据框写入 Postgres 数据库:
from sqlalchemy import create_engine, MetaData
engine = create_engine(r'postgresql://user:password@localhost:5432/db')
meta = MetaData(engine, schema='data_quality')
meta.reflect(engine, schema='data_quality')
pdsql = pd.io.sql.PandasSQLAlchemy(engine, meta=meta)
pdsql.to_sql(dataframe, table_name)
它运行良好,但现在 SQLAlchemy 在第 5 行抛出以下错误:
AttributeError: 'module' object has no attribute 'PandasSQLAlchemy'
我不确定它是否相关,但 Pandas 也同时崩溃了 - 就像在这个 google-api-python-client 问题中一样:
Could not Import Pandas: TypeError
我昨天安装了 google-api-python-client 并卸载它解决了 Pandas 的问题,但 SQLAlchemy 仍然无法工作。
【问题讨论】:
标签: python pandas sqlalchemy