Improve existing data check in 'export'
This commit is contained in:
parent
16a789cdf9
commit
a0a5384e5b
|
@ -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")
|
||||
|
||||
|
|
Loading…
Reference in New Issue