Skip to content

Commit

Permalink
fix(db): run in autocommit mode (#46)
Browse files Browse the repository at this point in the history
  • Loading branch information
gagantrivedi authored Oct 19, 2022
1 parent a344355 commit 49761e0
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 4 deletions.
5 changes: 2 additions & 3 deletions src/sse.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@

engine = create_async_engine("sqlite+aiosqlite:///:memory:", future=True)

engine.update_execution_options(isolation_level="AUTOCOMMIT")

router = APIRouter()


Expand Down Expand Up @@ -77,7 +79,6 @@ async def queue_environment_changes(environment_key: str):
"""INSERT OR REPLACE INTO environment(key) VALUES(:environment_key)"""
)
await session.execute(statement, {"environment_key": environment_key})
await session.commit()


@router.post(
Expand Down Expand Up @@ -119,7 +120,6 @@ async def did_environment_change() -> bool:
await session.execute(
delete(Identity).where(Identity.environment_key == environment_key)
)
await session.commit()
return environment_updated

async def get_updated_identities() -> List[str]:
Expand All @@ -134,7 +134,6 @@ async def get_updated_identities() -> List[str]:
await session.execute(
delete(Identity).where(Identity.environment_key == environment_key)
)
await session.commit()

return hashed_identities

Expand Down
1 change: 0 additions & 1 deletion src/sse_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,3 @@ async def put_identities(
statement,
{"identifier": identifier, "environment_key": environment_key},
)
await session.commit()

0 comments on commit 49761e0

Please sign in to comment.