]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
Update connect args for pymysql 1.0.0; aiomysql fixes
authorMike Bayer <mike_mp@zzzcomputing.com>
Thu, 7 Jan 2021 17:20:51 +0000 (12:20 -0500)
committerMike Bayer <mike_mp@zzzcomputing.com>
Thu, 7 Jan 2021 19:18:28 +0000 (14:18 -0500)
Fixed deprecation warnings that arose as a result of the release of PyMySQL
1.0, including deprecation warnings for the "db" and "passwd" parameters
now replaced with "database" and "password".

For the 1.4 version of this patch, we are also changing tox.ini
to refer to a local branch of aiomysql that fixes pymysql
compatibility issues.

Fixes: #5821
Change-Id: I93876b52b2d96b52308f22aeb4f244ac5766a82f
(cherry picked from commit 489301137a4d76e5a46d754ae9c91aad2b3d2c1f)

doc/build/changelog/unreleased_13/5821.rst [new file with mode: 0644]
lib/sqlalchemy/dialects/mysql/mysqldb.py
lib/sqlalchemy/dialects/mysql/pymysql.py
setup.cfg
setup.py
tox.ini

diff --git a/doc/build/changelog/unreleased_13/5821.rst b/doc/build/changelog/unreleased_13/5821.rst
new file mode 100644 (file)
index 0000000..a2c5d40
--- /dev/null
@@ -0,0 +1,8 @@
+.. change::
+    :tags: bug, mysql
+    :tickets: 5821
+
+    Fixed deprecation warnings that arose as a result of the release of PyMySQL
+    1.0, including deprecation warnings for the "db" and "passwd" parameters
+    now replaced with "database" and "password".
+
index 9eba49887b804ec1e325ad444cda0745ebe1ccbf..67e69c8492101c9ac76f849ca3ca90160e683e2c 100644 (file)
@@ -179,10 +179,13 @@ class MySQLDialect_mysqldb(MySQLDialect):
             connection, additional_tests
         )
 
-    def create_connect_args(self, url):
-        opts = url.translate_connect_args(
-            database="db", username="user", password="passwd"
-        )
+    def create_connect_args(self, url, _translate_args=None):
+        if _translate_args is None:
+            _translate_args = dict(
+                database="db", username="user", password="passwd"
+            )
+
+        opts = url.translate_connect_args(**_translate_args)
         opts.update(url.query)
 
         util.coerce_kw_type(opts, "compress", bool)
index 80ef1591bdd8ce19aaf60540b0d6356a0d6c2a58..da3e991536a3e7f2b050b62c7f4449ba21e66002 100644 (file)
@@ -61,6 +61,13 @@ class MySQLDialect_pymysql(MySQLDialect_mysqldb):
     def dbapi(cls):
         return __import__("pymysql")
 
+    def create_connect_args(self, url, _translate_args=None):
+        if _translate_args is None:
+            _translate_args = dict(username="user")
+        return super(MySQLDialect_pymysql, self).create_connect_args(
+            url, _translate_args=_translate_args
+        )
+
     def is_disconnect(self, e, connection, cursor):
         if super(MySQLDialect_pymysql, self).is_disconnect(
             e, connection, cursor
index f15ab5d7b67c1bfe8cd5565732ec696bf8b2e526..8aa3b6c78a38810425ec41924d4be6fd3308857c 100644 (file)
--- a/setup.cfg
+++ b/setup.cfg
@@ -1,3 +1,4 @@
+
 [egg_info]
 tag_build = dev
 
index d7181867f02679c7e5d0cb4fc1ff033865450113..891dcbf77c807cda123a0082375d93fb5b16654e 100644 (file)
--- a/setup.py
+++ b/setup.py
@@ -186,7 +186,10 @@ def run_setup(with_cext):
         distclass=Distribution,
         extras_require={
             "mysql": ["mysqlclient"],
-            "pymysql": ["pymysql"],
+            "pymysql": [
+                'pymysql; python_version>="3"',
+                'pymysql<1; python_version<"3"',
+            ],
             "postgresql": ["psycopg2"],
             "postgresql_psycopg2binary": ["psycopg2-binary"],
             "postgresql_pg8000": ["pg8000"],
diff --git a/tox.ini b/tox.ini
index 0f118bae63cb693539e49fcfc38b06db4ffda823..3809ed34e6c2cde3af56d70c980d6147474e3b46 100644 (file)
--- a/tox.ini
+++ b/tox.ini
@@ -25,7 +25,7 @@ deps=pytest>=4.6.11 # this can be 6.x once we are on python 3 only
      # needed only for correct profiling results
      # due to speed improvements in mysqlclient as of 1.4.0
      mysql: mysqlclient>=1.4.0
-     mysql: pymysql
+     mysql: .[pymysql]
      mysql: mysql-connector-python
 
      py3{,5,6,7,8,9,10,11}-oracle: cx_oracle>=7.0