]> 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:08:24 +0000 (14:08 -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

doc/build/changelog/unreleased_13/5821.rst [new file with mode: 0644]
lib/sqlalchemy/dialects/mysql/aiomysql.py
lib/sqlalchemy/dialects/mysql/mysqldb.py
lib/sqlalchemy/dialects/mysql/pymysql.py
setup.cfg
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 6381027e9f4696cca298ffbd05f70a10c1c9047b..f0665133f63615647aaf9110716fdeee5e965047 100644 (file)
@@ -264,10 +264,9 @@ class MySQLDialect_aiomysql(MySQLDialect_pymysql):
             return pool.AsyncAdaptedQueuePool
 
     def create_connect_args(self, url):
-        args, kw = super(MySQLDialect_aiomysql, self).create_connect_args(url)
-        if "passwd" in kw:
-            kw["password"] = kw.pop("passwd")
-        return args, kw
+        return super(MySQLDialect_aiomysql, self).create_connect_args(
+            url, _translate_args=dict(username="user", database="db")
+        )
 
     def is_disconnect(self, e, connection, cursor):
         if super(MySQLDialect_aiomysql, self).is_disconnect(
index ab5a78aad7d2cfa17d67612d53fe091c86835206..0318b50772c8d8fbf77a42d56a639364fe42fc7f 100644 (file)
@@ -177,10 +177,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 ad61c9e299fb5a777a82bdbf9ed51d2c7d56367d..0c321f854b308a231b45df1038145dea5c203036 100644 (file)
@@ -57,6 +57,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 e151769daca530ae167a10ca1b3752a51260c174..f7915e43b20432055531337e8d8ea88bddb261b9 100644 (file)
--- a/setup.cfg
+++ b/setup.cfg
@@ -65,7 +65,9 @@ postgresql_asyncpg =
     greenlet;python_version>="3"
 postgresql_psycopg2binary = psycopg2-binary
 postgresql_psycopg2cffi = psycopg2cffi
-pymysql = pymysql
+pymysql =
+    pymysql;python_version>="3"
+    pymysql<1;python_version<"3"
 aiomysql = aiomysql
 
 [egg_info]
diff --git a/tox.ini b/tox.ini
index 8c0e0b749897cab9926e03bf0028110bb4b5df39..8f2fd9de0fe00b7e2335fcf721e3542d93f700da 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
      postgresql: .[postgresql_pg8000]; python_version >= '3'
      mysql: .[mysql]
      mysql: .[pymysql]
-     mysql: .[aiomysql]; python_version >= '3'
+     mysql: git+https://github.com/sqlalchemy/aiomysql@sqlalchemy_tox; python_version >= '3'
      mysql: .[mariadb_connector]; python_version >= '3'
 
      # we should probably try to get mysql_connector back in the mix