Skip to content

Commit

Permalink
test create table in multi-processing
Browse files Browse the repository at this point in the history
  • Loading branch information
vikineema committed Feb 23, 2024
1 parent d2e0d4f commit 9f563f3
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions deafrica_conflux/db.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,9 @@ def create_table(engine: Engine, model):

if table_name not in tables_in_db:
_log.info(f"Creating the {table_name} table ...")
model.__table__.create(engine, checkfirst=False)
# Create the table only if it doesn't already exist
# using checkfirst=True because of multi-processing.
model.__table__.create(engine, checkfirst=True)
_log.info(f"{table_name} table created")
else:
_log.info(f"{table_name} table already exists.\nSkipping table creation")
Expand Down Expand Up @@ -381,8 +383,9 @@ def add_waterbody_observations_pq_files_to_db(
engine = get_engine_waterbodies()

# Ensure table exists.
table_name = WaterbodyObservation.__tablename__
table = get_table(engine=engine, table_name=table_name)
# table_name = WaterbodyObservation.__tablename__
# table = get_table(engine=engine, table_name=table_name)
table = create_waterbody_obs_table(engine=engine)
if table is None:
raise NoSuchTableError

Expand Down

0 comments on commit 9f563f3

Please sign in to comment.