1111from sqlalchemy .types import TypeEngine
1212
1313from databases .core import LOG_EXTRA , DatabaseURL
14- from databases .interfaces import ConnectionBackend , DatabaseBackend , TransactionBackend
14+ from databases .interfaces import (
15+ ConnectionBackend ,
16+ DatabaseBackend ,
17+ Record as RecordInterface ,
18+ TransactionBackend ,
19+ )
1520
1621logger = logging .getLogger ("databases" )
1722
@@ -78,7 +83,7 @@ def connection(self) -> "PostgresConnection":
7883 return PostgresConnection (self , self ._dialect )
7984
8085
81- class Record (Sequence ):
86+ class Record (RecordInterface ):
8287 __slots__ = (
8388 "_row" ,
8489 "_result_columns" ,
@@ -105,7 +110,7 @@ def __init__(
105110 self ._column_map , self ._column_map_int , self ._column_map_full = column_maps
106111
107112 @property
108- def _mapping (self ) -> asyncpg . Record :
113+ def _mapping (self ) -> typing . Mapping :
109114 return self ._row
110115
111116 def keys (self ) -> typing .KeysView :
@@ -171,15 +176,15 @@ async def release(self) -> None:
171176 self ._connection = await self ._database ._pool .release (self ._connection )
172177 self ._connection = None
173178
174- async def fetch_all (self , query : ClauseElement ) -> typing .List [typing . Sequence ]:
179+ async def fetch_all (self , query : ClauseElement ) -> typing .List [RecordInterface ]:
175180 assert self ._connection is not None , "Connection is not acquired"
176181 query_str , args , result_columns = self ._compile (query )
177182 rows = await self ._connection .fetch (query_str , * args )
178183 dialect = self ._dialect
179184 column_maps = self ._create_column_maps (result_columns )
180185 return [Record (row , result_columns , dialect , column_maps ) for row in rows ]
181186
182- async def fetch_one (self , query : ClauseElement ) -> typing .Optional [typing . Sequence ]:
187+ async def fetch_one (self , query : ClauseElement ) -> typing .Optional [RecordInterface ]:
183188 assert self ._connection is not None , "Connection is not acquired"
184189 query_str , args , result_columns = self ._compile (query )
185190 row = await self ._connection .fetchrow (query_str , * args )
0 commit comments