Skip to content
This repository was archived by the owner on Aug 19, 2025. It is now read-only.

Commit 5dcf235

Browse files
author
ansipunk
committed
S01E05
1 parent d7ff8e8 commit 5dcf235

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

databases/backends/psycopg.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import psycopg
44
import psycopg_pool
5+
from psycopg.rows import namedtuple_row
56
from sqlalchemy.engine.interfaces import Dialect
67
from sqlalchemy.dialects.postgresql.psycopg import PGDialect_psycopg
78
from 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

Comments
 (0)