0

I have two schema in PostgreSQL i.e public schema and Staging schema. Then from pandas dataframe I tried to create table in Staging schema, so I tried this method.

# establishing connection with database using sql alcemy
engine = create_engine('postgresql://postgres:root@localhost:5432/TestWarehouse')
sales_df_col.to_sql("Staging.tblsalesdata",engine)

Then instead of creating table in Staging schema, table name 'Staging.tblsaledata' was created in public schema. How can I create table 'tblsalesdata' into Staging schema from pandas?

1 Answer 1

1

According to documentation: pandas.DataFrame.to_sql, you need to pass schema as a separate parameters.

Try:

sales_df_col.to_sql("tblsalesdata",engine, schema='Staging')
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.