Created
April 18, 2021 13:12
-
-
Save tombohub/5653577369b6a22ed7f46fc45a4fe7e2 to your computer and use it in GitHub Desktop.
Revisions
-
tombohub renamed this gist
Apr 18, 2021 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
tombohub created this gist
Apr 18, 2021 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,19 @@ from sqlalchemy import create_engine from sqlalchemy.sql.expression import select db1_uri = 'db_uri_here' db2_uri = 'db_uri_here' db1_engine = create_engine(db1_uri) db2_engine = create_engine(db2_uri) db1_conn = db1_engine.connect() db2_conn = db2_engine.connect() table = 'table_name_here' query = select(table_name) df = pd.read_sql(query, db1_conn) df.to_sql(table, db2_conn, index=False) # repeat for each table, change table name