Last active
July 2, 2019 22:33
-
-
Save harshsinghal/38148dfc64a2ede93102fd9984c4da8f to your computer and use it in GitHub Desktop.
Grab data using pandas and insert into PostgreSQL db
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
# Used in blog post https://harshsinghal.dev/post/learn-sql-in-a-browser-with-postgresql-and-pgweb.html | |
import pandas as pd | |
from sqlalchemy import create_engine | |
iris = pd.read_csv('https://raw.githubusercontent.com/mwaskom/seaborn-data/master/iris.csv') | |
engine = create_engine('postgresql://postgres:postgres@localhost:5432/postgres') | |
iris.to_sql("iris", engine, if_exists = 'replace', index=False, chunksize=1000) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment