Skip to content

Commit

Permalink
Removing write-once protection in DBBackend (#13)
Browse files Browse the repository at this point in the history
  • Loading branch information
sidnarayanan authored Sep 4, 2024
1 parent 3fa16dc commit 918a61c
Showing 1 changed file with 2 additions and 11 deletions.
13 changes: 2 additions & 11 deletions src/aviary/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,21 +65,12 @@ class DBBackend:
@classmethod
async def populate_session(
cls,
uri: str | None = None,
uri: str,
base: type[DeclarativeBase] = Base,
engine_kwargs: dict[str, Any] | None = None,
sessionmaker_kwargs: dict[str, Any] | None = None,
) -> None:
if uri is not None:
if cls.uri is not None:
raise RuntimeError(
"Attempting to initialize DB backend connection, but one is already"
" established."
)
cls.uri = uri
assert (
cls.uri is not None
), "Cannot initialize DB backend without specifying a URI."
cls.uri = uri
cls.engine = engine = create_async_engine(cls.uri, **(engine_kwargs or {}))
async with engine.begin() as conn:
await conn.run_sync(base.metadata.create_all)
Expand Down

0 comments on commit 918a61c

Please sign in to comment.