2
2
3
3
import psycopg
4
4
import psycopg_pool
5
+ from psycopg .rows import namedtuple_row
5
6
from sqlalchemy .engine .interfaces import Dialect
6
7
from sqlalchemy .dialects .postgresql .psycopg import PGDialect_psycopg
7
8
from sqlalchemy .sql import ClauseElement
@@ -88,7 +89,7 @@ async def fetch_all(self, query: ClauseElement) -> typing.List[RecordInterface]:
88
89
89
90
query_str , args , result_columns = self ._compile (query )
90
91
91
- async with self ._connection .cursor () as cursor :
92
+ async with self ._connection .cursor (row_factory = namedtuple_row ) as cursor :
92
93
await cursor .execute (query_str , args )
93
94
rows = await cursor .fetchall ()
94
95
@@ -101,7 +102,7 @@ async def fetch_one(self, query: ClauseElement) -> typing.Optional[RecordInterfa
101
102
102
103
query_str , args , result_columns = self ._compile (query )
103
104
104
- async with self ._connection .cursor () as cursor :
105
+ async with self ._connection .cursor (row_factory = namedtuple_row ) as cursor :
105
106
await cursor .execute (query_str , args )
106
107
row = await cursor .fetchone ()
107
108
@@ -127,7 +128,7 @@ async def execute(self, query: ClauseElement) -> typing.Any:
127
128
128
129
query_str , args , _ = self ._compile (query )
129
130
130
- async with self ._connection .cursor () as cursor :
131
+ async with self ._connection .cursor (row_factory = namedtuple_row ) as cursor :
131
132
await cursor .execute (query_str , args )
132
133
133
134
async def execute_many (self , queries : typing .List [ClauseElement ]) -> None :
@@ -144,7 +145,7 @@ async def iterate(
144
145
query_str , args , result_columns = self ._compile (query )
145
146
column_maps = create_column_maps (result_columns )
146
147
147
- async with self ._connection .cursor () as cursor :
148
+ async with self ._connection .cursor (row_factory = namedtuple_row ) as cursor :
148
149
await cursor .execute (query_str , args )
149
150
150
151
while True :
0 commit comments