from db_setup import create_connection from pandas import DataFrame, read_csv, to_sql def create_dataframes() -> DataFrame: files = { "glacier": "../data/glacier.csv", "annual__data": "../data/annual_data.csv", "annual__change": "../data/annual_change.csv", "users": "../data/users.csv", } df_list = {} for csv in files.keys(): df_list[csv] = read_csv(files[csv], index=False) return df_list def insert_data(df_list, conn): for key, value in df_list.items(): value.to_sql(key, con=conn, if_exists="replace", index=False) def main(): conn = create_connection() df_list = create_dataframes() insert_data(df_list, conn) if __name__ == "__main__": main()