I\'m writing a pandas Dataframe to a Postgres database:
from sqlalchemy import create_engine, MetaData
engine = create_engine(r\'postgresql://user:password@local
I suppose you are using pandas 0.15. PandasSQLAlchemy
was not yet really public, and was renamed in pandas 0.15 to SQLDatabase
. So if you replace that in your code, it should work (so pdsql = pd.io.sql.SQLDatabase(engine, meta=meta)
).
However, starting from pandas 0.15, there is also schema support in the read_sql_table
and to_sql
functions, so it should not be needed to make a MetaData
and SQLDatabase
object manually. Instead, this should do it:
dataframe.to_sql(table_name, engine, schema='data_quality')
See the 0.15 release notes: http://pandas.pydata.org/pandas-docs/stable/whatsnew.html#improvements-in-the-sql-io-module