11import logging
22
33import sqlalchemy as sa
4-
54from aiohttp import web
65from models_library .projects import ProjectID
76from models_library .projects_nodes import Node , PartialNode
109from simcore_postgres_database .webserver_models import projects_nodes
1110from sqlalchemy .ext .asyncio import AsyncConnection
1211
13- from .exceptions import NodeNotFoundError
1412from ..db .plugin import get_asyncpg_engine
13+ from .exceptions import NodeNotFoundError
1514
1615_logger = logging .getLogger (__name__ )
1716
@@ -44,21 +43,18 @@ async def get(
4443 node_id : NodeID ,
4544) -> Node :
4645 async with transaction_context (get_asyncpg_engine (app ), connection ) as conn :
47- get_stmt = sa .select (
48- * _SELECTION_PROJECTS_NODES_DB_ARGS
49- ).where (
46+ get_stmt = sa .select (* _SELECTION_PROJECTS_NODES_DB_ARGS ).where (
5047 (projects_nodes .c .project_uuid == f"{ project_id } " )
5148 & (projects_nodes .c .node_id == f"{ node_id } " )
5249 )
5350
54- result = await conn .stream (get_stmt )
51+ result = await conn .execute (get_stmt )
5552 assert result # nosec
5653
57- row = await result .first ()
54+ row = result .one_or_none ()
5855 if row is None :
5956 raise NodeNotFoundError (
60- project_uuid = f"{ project_id } " ,
61- node_uuid = f"{ node_id } "
57+ project_uuid = f"{ project_id } " , node_uuid = f"{ node_id } "
6258 )
6359 assert row # nosec
6460 return Node .model_validate (row , from_attributes = True )
@@ -75,7 +71,7 @@ async def update(
7571 values = partial_node .model_dump (mode = "json" , exclude_unset = True )
7672
7773 async with transaction_context (get_asyncpg_engine (app ), connection ) as conn :
78- await conn .stream (
74+ await conn .execute (
7975 projects_nodes .update ()
8076 .values (** values )
8177 .where (
0 commit comments