Skip to content

Commit

Permalink
S01E05
Browse files Browse the repository at this point in the history
  • Loading branch information
ansipunk committed Mar 3, 2024
1 parent d7ff8e8 commit 5dcf235
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions databases/backends/psycopg.py
Expand Up @@ -2,6 +2,7 @@

import psycopg
import psycopg_pool
from psycopg.rows import namedtuple_row
from sqlalchemy.engine.interfaces import Dialect
from sqlalchemy.dialects.postgresql.psycopg import PGDialect_psycopg
from sqlalchemy.sql import ClauseElement
Expand Down Expand Up @@ -88,7 +89,7 @@ async def fetch_all(self, query: ClauseElement) -> typing.List[RecordInterface]:

query_str, args, result_columns = self._compile(query)

async with self._connection.cursor() as cursor:
async with self._connection.cursor(row_factory=namedtuple_row) as cursor:
await cursor.execute(query_str, args)
rows = await cursor.fetchall()

Expand All @@ -101,7 +102,7 @@ async def fetch_one(self, query: ClauseElement) -> typing.Optional[RecordInterfa

query_str, args, result_columns = self._compile(query)

async with self._connection.cursor() as cursor:
async with self._connection.cursor(row_factory=namedtuple_row) as cursor:
await cursor.execute(query_str, args)
row = await cursor.fetchone()

Expand All @@ -127,7 +128,7 @@ async def execute(self, query: ClauseElement) -> typing.Any:

query_str, args, _ = self._compile(query)

async with self._connection.cursor() as cursor:
async with self._connection.cursor(row_factory=namedtuple_row) as cursor:
await cursor.execute(query_str, args)

async def execute_many(self, queries: typing.List[ClauseElement]) -> None:
Expand All @@ -144,7 +145,7 @@ async def iterate(
query_str, args, result_columns = self._compile(query)
column_maps = create_column_maps(result_columns)

async with self._connection.cursor() as cursor:
async with self._connection.cursor(row_factory=namedtuple_row) as cursor:
await cursor.execute(query_str, args)

while True:
Expand Down

0 comments on commit 5dcf235

Please sign in to comment.