我想查询PostgreSQL数据库,并将输出作为数据帧返回.
我用"SqlAlchemy"创建了与数据库的连接:
from sqlalchemy import create_engine
engine = create_engine('postgresql://user@localhost:5432/mydb')
我将一个数据帧写入数据库表:
i=pd.read_csv(path)
i.to_sql('Stat_Table',engine,if_exists='replace')
基于docs,看起来像pd.read_sql_query()应接受SQLAlchemy引擎:
a=pd.read_sql_query('select * from Stat_Table',con=engine)
但它抛出了一个错误:
ProgrammingError: (ProgrammingError) relation "stat_table" does not exist
我使用的是Pandas 版本0.14.1.
正确的方法是什么?