Skip to content
This repository has been archived by the owner on Oct 1, 2024. It is now read-only.

Commit

Permalink
dds_glossary/database.py: improved init_engine
Browse files Browse the repository at this point in the history
  • Loading branch information
sami-m-g committed Jun 26, 2024
1 parent a52cb50 commit 9ed5691
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions dds_glossary/database.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,13 @@ def init_engine(
database_url = database_url or get_settings().DATABASE_URL.get_secret_value()
engine = create_engine(database_url)

if not database_exists(engine.url):
create_database(engine.url)
elif drop_database_flag:
if database_exists(engine.url):
if not drop_database_flag:
return engine
drop_database(engine.url)
create_database(engine.url)
engine.dispose()

create_database(engine.url)
Base.metadata.create_all(engine)
return engine

Expand Down

0 comments on commit 9ed5691

Please sign in to comment.