diff --git a/code/database/export.py b/code/database/export.py index 98e2817..550585a 100644 --- a/code/database/export.py +++ b/code/database/export.py @@ -1,3 +1,4 @@ +from app.models import Annual_Data, Glacier, User from database.constants import DB_NAME, DB_PW, DB_USER from pandas import DataFrame, read_csv from sqlalchemy import create_engine, engine @@ -25,8 +26,10 @@ def create_dataframes() -> DataFrame: def insert_data(df_list, conn): - if conn.table_names() is not None: - return + models = [Glacier, Annual_Data, User] + for model in models: + if model.query.first() is not None: + return for key, value in df_list.items(): value.to_sql(key, con=conn, index=False, if_exists="append")