Added support to the asyncpg dialect to return the ``cursor.rowcount``
value for SELECT statements when available. While this is not a typical use
for ``cursor.rowcount``, the other PostgreSQL dialects generally provide
this value. Pull request courtesy Michael Gorven.
Fixes: #9048
Closes: #9049
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/9049
Pull-request-sha:
df16160530c6001d99de059995ad5047a75fb7b0
Change-Id: I095b866779ccea7e4d50bc841fef7605e61c667f
(cherry picked from commit
9c502f5788737fa65029716c73fe0f65f3dafb53)
--- /dev/null
+.. change::
+ :tags: bug, postgresql
+ :tickets: 9048
+ :versions: 2.0.0
+
+ Added support to the asyncpg dialect to return the ``cursor.rowcount``
+ value for SELECT statements when available. While this is not a typical use
+ for ``cursor.rowcount``, the other PostgreSQL dialects generally provide
+ this value. Pull request courtesy Michael Gorven.
status = prepared_stmt.get_statusmsg()
reg = re.match(
- r"(?:UPDATE|DELETE|INSERT \d+) (\d+)", status
+ r"(?:SELECT|UPDATE|DELETE|INSERT \d+) (\d+)", status
)
if reg:
self.rowcount = int(reg.group(1))
with engine.connect() as conn:
ne_(conn.connection.status, STATUS_IN_TRANSACTION)
+ def test_select_rowcount(self):
+ conn = testing.db.connect()
+ cursor = conn.exec_driver_sql("SELECT 1")
+ eq_(cursor.rowcount, 1)
+
class AutocommitTextTest(test_deprecations.AutocommitTextTest):
__only_on__ = "postgresql"