Last active
March 21, 2022 13:44
-
-
Save 00krishna/9026574 to your computer and use it in GitHub Desktop.
Connect from python pandas to a postgresql database and pull data.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import psycopg2 as pg | |
import pandas.io.sql as psql | |
# get connected to the database | |
connection = pg.connect("dbname=mydatabase user=postgres") | |
dataframe = psql.frame_query("SELECT * FROM <tablename>", connection) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
maybe this article can help
https://www.datacamp.com/community/tutorials/tutorial-postgresql-python