From 5fba7db9be7a03076d50051fb84dade31d55262e Mon Sep 17 00:00:00 2001 From: Mike Bayer Date: Thu, 10 Nov 2016 17:08:06 -0500 Subject: Quote URL tokens with semicolons for pyodbc, adodbapi Fixed bug in pyodbc dialect (as well as in the mostly non-working adodbapi dialect) whereby a semicolon present in the password or username fields could be interpreted as a separator for another token; the values are now quoted when semicolons are present. Change-Id: I5f99fd8db53ebf8e805e7d9d60bc09b8f1af603f Fixes: #3762 --- lib/sqlalchemy/dialects/mssql/adodbapi.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'lib/sqlalchemy/dialects/mssql/adodbapi.py') diff --git a/lib/sqlalchemy/dialects/mssql/adodbapi.py b/lib/sqlalchemy/dialects/mssql/adodbapi.py index 60fa25d34..a85ce5a57 100644 --- a/lib/sqlalchemy/dialects/mssql/adodbapi.py +++ b/lib/sqlalchemy/dialects/mssql/adodbapi.py @@ -56,7 +56,14 @@ class MSDialect_adodbapi(MSDialect): ) def create_connect_args(self, url): - keys = url.query + def check_quote(token): + if ";" in str(token): + token = "'%s'" % token + return token + + keys = dict( + (k, check_quote(v)) for k, v in url.query.items() + ) connectors = ["Provider=SQLOLEDB"] if 'port' in keys: -- cgit v1.2.1