From 565a56153149f0d27934abf1bc1a7fa81e59c484 Mon Sep 17 00:00:00 2001 From: Gord Thompson Date: Wed, 4 Dec 2019 03:47:24 -0700 Subject: [PATCH] Add pass through exact pyodbc connection string. --- lib/sqlalchemy/dialects/mysql/pyodbc.py | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/lib/sqlalchemy/dialects/mysql/pyodbc.py b/lib/sqlalchemy/dialects/mysql/pyodbc.py index c533595bbe..ff69ec3451 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 @@ -25,7 +25,22 @@ MySQL Connector/ODBC and specify the "ANSI" (**not** "Unicode") version of the driver in your DSN or connection string. -""" +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 import re import sys -- 2.47.2