Join the Stack Overflow Community
Stack Overflow is a community of 6.4 million programmers, just like you, helping each other.
Join them; it only takes a minute:
Sign up

Is it possible to write a Pandas dataframe to PostgreSQL database using psycopg2?

Endgoal is to be able to write a Pandas dataframe to Amazon RDS PostgreSQL instance.

share|improve this question
up vote 1 down vote accepted

If you use a SQLAlchemy engine around psycopg2, you could probably use df.to_sql. See: http://pandas.pydata.org/pandas-docs/stable/generated/pandas.DataFrame.to_sql.html

share|improve this answer
    
Thank you, I got SQLAlchemy to work. After using df.to_sql to write is commit necessary? If so, how would I commit in SQLAlchemy? It appears I need to create a session object then somehow add my query to it and then commit. – verkter Nov 29 '15 at 20:13
    
I believe to_sql performs the commit. – David Maust Dec 5 '15 at 6:25

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.