Skip to content

Commit

Permalink
Add tds_version paramenter to pymssql.connet().
Browse files Browse the repository at this point in the history
It has a default value of '7.1' to match the default value of the
underlying _mssql API.

We plan to change both of these defaults to None and to not
enforce any TDS protocol version by default in pymmsql 2.2.
  • Loading branch information
ramiro committed Oct 19, 2015
1 parent 593c736 commit 8b758d5
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
12 changes: 11 additions & 1 deletion docs/ref/pymssql.rst
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ Functions
.. function:: connect(server='.', user='', password='', database='', \
timeout=0, login_timeout=60, charset='UTF-8', \
as_dict=False, host='', appname=None, port='1433',\
conn_properties)
conn_properties, autocommit=False, tds_version='7.1')

Constructor for creating a connection to the database. Returns a
:class:`Connection` object.
Expand Down Expand Up @@ -58,6 +58,10 @@ Functions
establishment. Can be a string or another kind
of iterable of strings. Default value: See
:class:`_mssql.connect <_mssql.MSSQLConnection>`
:keyword autocommit: Whether to use default autocommiting mode or not
:type autocommit: boolean
:keyword tds_version: TDS protocol version to use.
:type tds_version: string

.. warning::
Currently, setting *timeout* or *login_timeout* have a process-wide
Expand All @@ -77,6 +81,12 @@ Functions
.. versionadded:: 2.1.1
The *conn_properties* argument.

.. versionadded:: 2.1.1
The *autocommit* argument.

.. versionadded:: 2.1.2
The *tds_version* argument.

.. function:: get_dbversion()

TBD
Expand Down
8 changes: 5 additions & 3 deletions pymssql.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -584,7 +584,7 @@ cdef class Cursor:

def connect(server='.', user='', password='', database='', timeout=0,
login_timeout=60, charset='UTF-8', as_dict=False,
host='', appname=None, port='1433', conn_properties=None, autocommit=False):
host='', appname=None, port='1433', conn_properties=None, autocommit=False, tds_version='7.1'):
"""
Constructor for creating a connection to the database. Returns a
Connection object.
Expand Down Expand Up @@ -612,8 +612,10 @@ def connect(server='.', user='', password='', database='', timeout=0,
:keyword conn_properties: SQL queries to send to the server upon connection
establishment. Can be a string or another kind
of iterable of strings
:keyword autocommit whether to use default autocommiting mode or not
:keyword autocommit: Whether to use default autocommiting mode or not
:type autocommit: boolean
:keyword tds_version: TDS protocol version to use.
:type tds_version: string
"""

# set the login timeout
Expand All @@ -636,7 +638,7 @@ def connect(server='.', user='', password='', database='', timeout=0,
try:
conn = _mssql.connect(server=server, user=user, password=password,
charset=charset, database=database,
appname=appname, port=port,
appname=appname, port=port, tds_version=tds_version,
conn_properties=conn_properties)

except _mssql.MSSQLDatabaseException, e:
Expand Down

0 comments on commit 8b758d5

Please sign in to comment.