import pandas as pd
import os
import sqlalchemyfrom sqlalchemy import create_engine
from sqlalchemy import inspect
SOURCE_DRIVER = os.environ.get('MS SQL SERVER DRIVER')
source_database_name = 'olympics_database'
destination_database_connection = sqlalchemy.create_engine(f'postgresql://postgres:{postgresdbpass}@localhost:5432/olympics_db')
df.to_sql("table_name", destination_database_connection, if_exists = append)
table_names_list = inspector.get_table_names()
#Above code generates a list of all tables in the database
for table in source_conn.table_names_list():
df = pd.read_sql(f'select * from [olympics_database].[dbo].{table}', source_conn)
df.to_sql(f'{table}', destination_conn, if_exists = 'append', index = False)