]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
Add pass through exact pyodbc connection string.
authorGord Thompson <gord@gordthompson.com>
Wed, 4 Dec 2019 10:47:24 +0000 (03:47 -0700)
committerMike Bayer <mike_mp@zzzcomputing.com>
Wed, 18 Dec 2019 23:01:51 +0000 (18:01 -0500)
(cherry picked from commit 565a56153149f0d27934abf1bc1a7fa81e59c484)

lib/sqlalchemy/dialects/mysql/pyodbc.py

index ae8bfece10746e4a49bef5340ef43c6ab40c931c..04f7e5f9cd5d8729c6ef61136f219c384ec53098 100644 (file)
@@ -5,7 +5,7 @@
 # This module is part of SQLAlchemy and is released under
 # the MIT License: http://www.opensource.org/licenses/mit-license.php
 
-"""
+r"""
 
 
 .. dialect:: mysql+pyodbc
        (see http://code.google.com/p/pyodbc/issues/detail?id=25).
        Other dialects for MySQL are recommended.
 
-"""
+Pass through exact pyodbc connection string::
+
+    import urllib
+    connection_string = (
+        'DRIVER=MySQL ODBC 8.0 ANSI Driver;'
+        'SERVER=localhost;'
+        'PORT=3307;'
+        'DATABASE=mydb;'
+        'UID=root;'
+        'PWD=(whatever);'
+        'charset=utf8mb4;'
+    )
+    params = urllib.parse.quote_plus(connection_string)
+    connection_uri = "mysql+pyodbc:///?odbc_connect=%s" % params
+
+"""  # noqa
 
 from .base import MySQLDialect, MySQLExecutionContext
 from ...connectors.pyodbc import PyODBCConnector