Created
February 3, 2020 21:42
-
-
Save mujahidk/f0dfe53a558572d48c682761f69a842b to your computer and use it in GitHub Desktop.
Python connection to PostgreSQL and Pandas
This file contains 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
# Shell | |
# pip --version | |
# pip install psycopg2-binary | |
import psycopg2 as pg | |
import pandas as pd | |
connection = pg.connect("host='host-name-here' dbname=DBNAME user='username' password='password'") | |
df = pd.read_sql_query("SELECT * FROM product", connection) | |
df.sample(5) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment