22
33import psycopg
44import psycopg_pool
5+ from psycopg .rows import namedtuple_row
56from sqlalchemy .engine .interfaces import Dialect
67from sqlalchemy .dialects .postgresql .psycopg import PGDialect_psycopg
78from sqlalchemy .sql import ClauseElement
@@ -88,7 +89,7 @@ async def fetch_all(self, query: ClauseElement) -> typing.List[RecordInterface]:
8889
8990 query_str , args , result_columns = self ._compile (query )
9091
91- async with self ._connection .cursor () as cursor :
92+ async with self ._connection .cursor (row_factory = namedtuple_row ) as cursor :
9293 await cursor .execute (query_str , args )
9394 rows = await cursor .fetchall ()
9495
@@ -101,7 +102,7 @@ async def fetch_one(self, query: ClauseElement) -> typing.Optional[RecordInterfa
101102
102103 query_str , args , result_columns = self ._compile (query )
103104
104- async with self ._connection .cursor () as cursor :
105+ async with self ._connection .cursor (row_factory = namedtuple_row ) as cursor :
105106 await cursor .execute (query_str , args )
106107 row = await cursor .fetchone ()
107108
@@ -127,7 +128,7 @@ async def execute(self, query: ClauseElement) -> typing.Any:
127128
128129 query_str , args , _ = self ._compile (query )
129130
130- async with self ._connection .cursor () as cursor :
131+ async with self ._connection .cursor (row_factory = namedtuple_row ) as cursor :
131132 await cursor .execute (query_str , args )
132133
133134 async def execute_many (self , queries : typing .List [ClauseElement ]) -> None :
@@ -144,7 +145,7 @@ async def iterate(
144145 query_str , args , result_columns = self ._compile (query )
145146 column_maps = create_column_maps (result_columns )
146147
147- async with self ._connection .cursor () as cursor :
148+ async with self ._connection .cursor (row_factory = namedtuple_row ) as cursor :
148149 await cursor .execute (query_str , args )
149150
150151 while True :
0 commit comments