Issues

Issue #3173 new

add count_matched_rows API for all MySQL dialects

Mike Bayer
repo owner created an issue

includes:

  • count_matched_rows flag

  • documentation

  • implementation for all dialects, MySQLdb, MySQL-connector, OurSQL, etc.

  • unit tests, at least against create_connect_args()

basic idea:

diff --git a/lib/sqlalchemy/dialects/mysql/base.py b/lib/sqlalchemy/dialects/mysql/base.py
index 012d178..0327043 100644
--- a/lib/sqlalchemy/dialects/mysql/base.py
+++ b/lib/sqlalchemy/dialects/mysql/base.py
@@ -2256,10 +2256,12 @@ class MySQLDialect(default.DefaultDialect):
         })
     ]

-    def __init__(self, isolation_level=None, **kwargs):
+    def __init__(
+            self, isolation_level=None, count_matched_rows=True, **kwargs):
         kwargs.pop('use_ansiquotes', None)   # legacy
         default.DefaultDialect.__init__(self, **kwargs)
         self.isolation_level = isolation_level
+        self.count_matched_rows = count_matched_rows

     def on_connect(self):
         if self.isolation_level is not None:
classics-MacBook-Pro-2:sqlalchemy classic$ git diff
diff --git a/lib/sqlalchemy/dialects/mysql/base.py b/lib/sqlalchemy/dialects/mysql/base.py
index 012d178..0327043 100644
--- a/lib/sqlalchemy/dialects/mysql/base.py
+++ b/lib/sqlalchemy/dialects/mysql/base.py
@@ -2256,10 +2256,12 @@ class MySQLDialect(default.DefaultDialect):
         })
     ]

-    def __init__(self, isolation_level=None, **kwargs):
+    def __init__(
+            self, isolation_level=None, count_matched_rows=True, **kwargs):
         kwargs.pop('use_ansiquotes', None)   # legacy
         default.DefaultDialect.__init__(self, **kwargs)
         self.isolation_level = isolation_level
+        self.count_matched_rows = count_matched_rows

     def on_connect(self):
         if self.isolation_level is not None:

Comments (0)

  1. Log in to comment