Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from sqlalchemy import create_engine
- # Port 5439 for Redshift
- engine = create_engine("postgresql://user@localhost:5432/mydb")
- df = pd.read_sql_query("select * from airlines", engine)
- # Get results in chunks
- for chunk in pd.read_sql_query("select * from airlines", engine, chunksize=5):
- print(chunk)
- # Writing back
- df.to_sql(
- "table"
- schema="schema"
- # fail, replace or append
- if_exists="append",
- # write back in chunks
- chunksize = 10000
- )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement