From: Mike Bayer Date: Thu, 31 Oct 2019 14:30:46 +0000 (-0400) Subject: Improve SQL Server pyodbc documentation X-Git-Tag: rel_1_4_0b1~643 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=65466dec6346ad84340af1cf3e431020add0f9a5;p=thirdparty%2Fsqlalchemy%2Fsqlalchemy.git Improve SQL Server pyodbc documentation While we were told years ago that ODBC is intended to be used with DSNs only, however this use does not correspond well with how most other database connectivity systems work in that modern systems already have their own registries of connection information in any case, meaning this is usually the best place to add details such as hostnames and driver names, rather than having them locked away in a server-specific ODBC registry. So here we dial back the language that one style or another of connecting is "preferred"; both styles are supported equally, and the critical advantage of hostname mapping in that the target database name is both explicit as well as modifyable is also added. Add additional background for how DSNs work and refine other sentences. "URL encoding" is the correct terminology for adding spaces and special characters to a URL. Change-Id: I13a74432976e6d3166633b98f9bb84c4856caac8 --- diff --git a/lib/sqlalchemy/dialects/mssql/pyodbc.py b/lib/sqlalchemy/dialects/mssql/pyodbc.py index 2246886a32..f12fb5eade 100644 --- a/lib/sqlalchemy/dialects/mssql/pyodbc.py +++ b/lib/sqlalchemy/dialects/mssql/pyodbc.py @@ -21,8 +21,11 @@ detailed in `ConnectionStrings `_ -into the driver using the parameter ``odbc_connect``. The delimeters must be -URL escaped, however, as illustrated below using ``urllib.parse.quote_plus``:: +A PyODBC connection string can also be sent in pyodbc's format directly, as +specified in `ConnectionStrings +`_ into the driver +using the parameter ``odbc_connect``. The delimeters must be URL encoded, as +illustrated below using ``urllib.parse.quote_plus``:: import urllib params = urllib.parse.quote_plus("DRIVER={SQL Server Native Client 10.0};SERVER=dagger;DATABASE=test;UID=user;PWD=password")