From: Gord Thompson Date: Wed, 4 Dec 2019 10:47:24 +0000 (-0700) Subject: Add pass through exact pyodbc connection string. X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2ba70a6400905894fa0889c94907983160d95c55;p=thirdparty%2Fsqlalchemy%2Fsqlalchemy.git Add pass through exact pyodbc connection string. (cherry picked from commit 565a56153149f0d27934abf1bc1a7fa81e59c484) --- diff --git a/lib/sqlalchemy/dialects/mysql/pyodbc.py b/lib/sqlalchemy/dialects/mysql/pyodbc.py index ae8bfece10..04f7e5f9cd 100644 --- a/lib/sqlalchemy/dialects/mysql/pyodbc.py +++ b/lib/sqlalchemy/dialects/mysql/pyodbc.py @@ -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 @@ -20,7 +20,22 @@ (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