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

Commit e44fe3b

Browse files
committed
Fix: execute() should return rows affected by operation.
1 parent 88b381a commit e44fe3b

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

databases/backends/mysql.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ async def execute(self, query: ClauseElement) -> typing.Any:
131131
cursor = await self._connection.cursor()
132132
try:
133133
await cursor.execute(query, args)
134-
return cursor.lastrowid
134+
return cursor.rowcount
135135
finally:
136136
await cursor.close()
137137

databases/backends/sqlite.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,8 +112,9 @@ async def execute(self, query: ClauseElement) -> typing.Any:
112112
assert self._connection is not None, "Connection is not acquired"
113113
query, args, context = self._compile(query)
114114
cursor = await self._connection.execute(query, args)
115+
rowcount = cursor.rowcount
115116
await cursor.close()
116-
return cursor.lastrowid
117+
return rowcount
117118

118119
async def execute_many(self, queries: typing.List[ClauseElement]) -> None:
119120
assert self._connection is not None, "Connection is not acquired"

0 commit comments

Comments
 (0)