Skip to content

Instantly share code, notes, and snippets.

@MLKrisJohnson
Created August 13, 2018 15:01
Show Gist options
  • Save MLKrisJohnson/86942cf1d7b19ba4fe7f6187fc82c256 to your computer and use it in GitHub Desktop.
Save MLKrisJohnson/86942cf1d7b19ba4fe7f6187fc82c256 to your computer and use it in GitHub Desktop.
Example of connecting to a PostgreSQL database and getting a Pandas DataFrame for a table
import psycopg2 as pg
import pandas as pd
conn = pg.connect(database="mydatabase",
user="myuser",
password="mypassword")
df = pd.read_sql('select * from event', conn)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment