File tree Expand file tree Collapse file tree 2 files changed +5
-5
lines changed
packages/postgres-database
src/simcore_postgres_database Expand file tree Collapse file tree 2 files changed +5
-5
lines changed Original file line number Diff line number Diff line change 88
99
1010@asynccontextmanager
11- async def get_or_create_connection (
11+ async def pass_or_acquire_connection (
1212 engine : AsyncEngine , connection : AsyncConnection | None = None
1313) -> AsyncIterator [AsyncConnection ]:
1414 # NOTE: When connection is passed, the engine is actually not needed
@@ -30,7 +30,7 @@ async def get_or_create_connection(
3030async def transaction_context (
3131 engine : AsyncEngine , connection : AsyncConnection | None = None
3232):
33- async with get_or_create_connection (engine , connection ) as conn :
33+ async with pass_or_acquire_connection (engine , connection ) as conn :
3434 if conn .in_transaction ():
3535 async with conn .begin_nested (): # inner transaction (savepoint)
3636 yield conn
Original file line number Diff line number Diff line change 1010import sqlalchemy as sa
1111from simcore_postgres_database .models .tags import tags
1212from simcore_postgres_database .utils_repos import (
13- get_or_create_connection ,
13+ pass_or_acquire_connection ,
1414 transaction_context ,
1515)
1616from sqlalchemy .exc import IntegrityError
@@ -100,7 +100,7 @@ async def get_by_id(
100100 * ,
101101 row_id : int ,
102102 ) -> dict [str , Any ] | None :
103- async with get_or_create_connection (self .engine , connection ) as conn :
103+ async with pass_or_acquire_connection (self .engine , connection ) as conn :
104104 result = await conn .execute (
105105 sa .select (self .table ).where (self .table .c .id == row_id )
106106 )
@@ -114,7 +114,7 @@ async def get_page(
114114 limit : int ,
115115 offset : int = 0 ,
116116 ) -> _PageTuple :
117- async with get_or_create_connection (self .engine , connection ) as conn :
117+ async with pass_or_acquire_connection (self .engine , connection ) as conn :
118118 # Compute total count
119119 total_count_query = sa .select (sa .func .count ()).select_from (self .table )
120120 total_count_result = await conn .execute (total_count_query )
You can’t perform that action at this time.
0 commit comments