Skip to content
This repository was archived by the owner on Aug 19, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions databases/backends/aiopg.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from sqlalchemy.dialects.postgresql.psycopg2 import PGDialect_psycopg2
from sqlalchemy.engine.cursor import CursorResultMetaData
from sqlalchemy.engine.interfaces import Dialect, ExecutionContext
from sqlalchemy.engine.result import Row
from sqlalchemy.engine.row import Row
from sqlalchemy.sql import ClauseElement
from sqlalchemy.sql.ddl import DDLElement

Expand Down Expand Up @@ -114,10 +114,10 @@ async def release(self) -> None:

async def fetch_all(self, query: ClauseElement) -> typing.List[typing.Mapping]:
assert self._connection is not None, "Connection is not acquired"
query, args, context = self._compile(query)
query_str, args, context = self._compile(query)
cursor = await self._connection.cursor()
try:
await cursor.execute(query, args)
await cursor.execute(query_str, args)
rows = await cursor.fetchall()
metadata = CursorResultMetaData(context, cursor.description)
return [
Expand All @@ -135,10 +135,10 @@ async def fetch_all(self, query: ClauseElement) -> typing.List[typing.Mapping]:

async def fetch_one(self, query: ClauseElement) -> typing.Optional[typing.Mapping]:
assert self._connection is not None, "Connection is not acquired"
query, args, context = self._compile(query)
query_str, args, context = self._compile(query)
cursor = await self._connection.cursor()
try:
await cursor.execute(query, args)
await cursor.execute(query_str, args)
row = await cursor.fetchone()
if row is None:
return None
Expand All @@ -155,10 +155,10 @@ async def fetch_one(self, query: ClauseElement) -> typing.Optional[typing.Mappin

async def execute(self, query: ClauseElement) -> typing.Any:
assert self._connection is not None, "Connection is not acquired"
query, args, context = self._compile(query)
query_str, args, context = self._compile(query)
cursor = await self._connection.cursor()
try:
await cursor.execute(query, args)
await cursor.execute(query_str, args)
return cursor.lastrowid
finally:
cursor.close()
Expand All @@ -177,10 +177,10 @@ async def iterate(
self, query: ClauseElement
) -> typing.AsyncGenerator[typing.Any, None]:
assert self._connection is not None, "Connection is not acquired"
query, args, context = self._compile(query)
query_str, args, context = self._compile(query)
cursor = await self._connection.cursor()
try:
await cursor.execute(query, args)
await cursor.execute(query_str, args)
metadata = CursorResultMetaData(context, cursor.description)
async for row in cursor:
yield Row(
Expand Down
18 changes: 9 additions & 9 deletions databases/backends/mysql.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from sqlalchemy.dialects.mysql import pymysql
from sqlalchemy.engine.cursor import CursorResultMetaData
from sqlalchemy.engine.interfaces import Dialect, ExecutionContext
from sqlalchemy.engine.result import Row
from sqlalchemy.engine.row import Row
from sqlalchemy.sql import ClauseElement
from sqlalchemy.sql.ddl import DDLElement

Expand Down Expand Up @@ -102,10 +102,10 @@ async def release(self) -> None:

async def fetch_all(self, query: ClauseElement) -> typing.List[typing.Mapping]:
assert self._connection is not None, "Connection is not acquired"
query, args, context = self._compile(query)
query_str, args, context = self._compile(query)
cursor = await self._connection.cursor()
try:
await cursor.execute(query, args)
await cursor.execute(query_str, args)
rows = await cursor.fetchall()
metadata = CursorResultMetaData(context, cursor.description)
return [
Expand All @@ -123,10 +123,10 @@ async def fetch_all(self, query: ClauseElement) -> typing.List[typing.Mapping]:

async def fetch_one(self, query: ClauseElement) -> typing.Optional[typing.Mapping]:
assert self._connection is not None, "Connection is not acquired"
query, args, context = self._compile(query)
query_str, args, context = self._compile(query)
cursor = await self._connection.cursor()
try:
await cursor.execute(query, args)
await cursor.execute(query_str, args)
row = await cursor.fetchone()
if row is None:
return None
Expand All @@ -143,10 +143,10 @@ async def fetch_one(self, query: ClauseElement) -> typing.Optional[typing.Mappin

async def execute(self, query: ClauseElement) -> typing.Any:
assert self._connection is not None, "Connection is not acquired"
query, args, context = self._compile(query)
query_str, args, context = self._compile(query)
cursor = await self._connection.cursor()
try:
await cursor.execute(query, args)
await cursor.execute(query_str, args)
if cursor.lastrowid == 0:
return cursor.rowcount
return cursor.lastrowid
Expand All @@ -167,10 +167,10 @@ async def iterate(
self, query: ClauseElement
) -> typing.AsyncGenerator[typing.Any, None]:
assert self._connection is not None, "Connection is not acquired"
query, args, context = self._compile(query)
query_str, args, context = self._compile(query)
cursor = await self._connection.cursor()
try:
await cursor.execute(query, args)
await cursor.execute(query_str, args)
metadata = CursorResultMetaData(context, cursor.description)
async for row in cursor:
yield Row(
Expand Down
16 changes: 8 additions & 8 deletions databases/backends/postgres.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,16 +170,16 @@ async def release(self) -> None:

async def fetch_all(self, query: ClauseElement) -> typing.List[typing.Mapping]:
assert self._connection is not None, "Connection is not acquired"
query, args, result_columns = self._compile(query)
rows = await self._connection.fetch(query, *args)
query_str, args, result_columns = self._compile(query)
rows = await self._connection.fetch(query_str, *args)
dialect = self._dialect
column_maps = self._create_column_maps(result_columns)
return [Record(row, result_columns, dialect, column_maps) for row in rows]

async def fetch_one(self, query: ClauseElement) -> typing.Optional[typing.Mapping]:
assert self._connection is not None, "Connection is not acquired"
query, args, result_columns = self._compile(query)
row = await self._connection.fetchrow(query, *args)
query_str, args, result_columns = self._compile(query)
row = await self._connection.fetchrow(query_str, *args)
if row is None:
return None
return Record(
Expand All @@ -206,8 +206,8 @@ async def fetch_val(

async def execute(self, query: ClauseElement) -> typing.Any:
assert self._connection is not None, "Connection is not acquired"
query, args, result_columns = self._compile(query)
return await self._connection.fetchval(query, *args)
query_str, args, result_columns = self._compile(query)
return await self._connection.fetchval(query_str, *args)

async def execute_many(self, queries: typing.List[ClauseElement]) -> None:
assert self._connection is not None, "Connection is not acquired"
Expand All @@ -222,9 +222,9 @@ async def iterate(
self, query: ClauseElement
) -> typing.AsyncGenerator[typing.Any, None]:
assert self._connection is not None, "Connection is not acquired"
query, args, result_columns = self._compile(query)
query_str, args, result_columns = self._compile(query)
column_maps = self._create_column_maps(result_columns)
async for row in self._connection.cursor(query, *args):
async for row in self._connection.cursor(query_str, *args):
yield Record(row, result_columns, self._dialect, column_maps)

def transaction(self) -> TransactionBackend:
Expand Down
18 changes: 9 additions & 9 deletions databases/backends/sqlite.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from sqlalchemy.dialects.sqlite import pysqlite
from sqlalchemy.engine.cursor import CursorResultMetaData
from sqlalchemy.engine.interfaces import Dialect, ExecutionContext
from sqlalchemy.engine.result import Row
from sqlalchemy.engine.row import Row
from sqlalchemy.sql import ClauseElement
from sqlalchemy.sql.ddl import DDLElement

Expand Down Expand Up @@ -88,9 +88,9 @@ async def release(self) -> None:

async def fetch_all(self, query: ClauseElement) -> typing.List[typing.Mapping]:
assert self._connection is not None, "Connection is not acquired"
query, args, context = self._compile(query)
query_str, args, context = self._compile(query)

async with self._connection.execute(query, args) as cursor:
async with self._connection.execute(query_str, args) as cursor:
rows = await cursor.fetchall()
metadata = CursorResultMetaData(context, cursor.description)
return [
Expand All @@ -106,9 +106,9 @@ async def fetch_all(self, query: ClauseElement) -> typing.List[typing.Mapping]:

async def fetch_one(self, query: ClauseElement) -> typing.Optional[typing.Mapping]:
assert self._connection is not None, "Connection is not acquired"
query, args, context = self._compile(query)
query_str, args, context = self._compile(query)

async with self._connection.execute(query, args) as cursor:
async with self._connection.execute(query_str, args) as cursor:
row = await cursor.fetchone()
if row is None:
return None
Expand All @@ -123,9 +123,9 @@ async def fetch_one(self, query: ClauseElement) -> typing.Optional[typing.Mappin

async def execute(self, query: ClauseElement) -> typing.Any:
assert self._connection is not None, "Connection is not acquired"
query, args, context = self._compile(query)
query_str, args, context = self._compile(query)
async with self._connection.cursor() as cursor:
await cursor.execute(query, args)
await cursor.execute(query_str, args)
if cursor.lastrowid == 0:
return cursor.rowcount
return cursor.lastrowid
Expand All @@ -139,8 +139,8 @@ async def iterate(
self, query: ClauseElement
) -> typing.AsyncGenerator[typing.Any, None]:
assert self._connection is not None, "Connection is not acquired"
query, args, context = self._compile(query)
async with self._connection.execute(query, args) as cursor:
query_str, args, context = self._compile(query)
async with self._connection.execute(query_str, args) as cursor:
metadata = CursorResultMetaData(context, cursor.description)
async for row in cursor:
yield Row(
Expand Down