{"action":"opened","issue":{"url":"https://api.github.com/repos/pymssql/pymssql/issues/323","labels_url":"https://api.github.com/repos/pymssql/pymssql/issues/323/labels{/name}","comments_url":"https://api.github.com/repos/pymssql/pymssql/issues/323/comments","events_url":"https://api.github.com/repos/pymssql/pymssql/issues/323/events","html_url":"https://github.com/pymssql/pymssql/issues/323","id":68768067,"number":323,"title":"tds_version not available in pymssql.connect","user":{"login":"cweimann","id":577454,"avatar_url":"https://avatars.githubusercontent.com/u/577454?v=3","gravatar_id":"","url":"https://api.github.com/users/cweimann","html_url":"https://github.com/cweimann","followers_url":"https://api.github.com/users/cweimann/followers","following_url":"https://api.github.com/users/cweimann/following{/other_user}","gists_url":"https://api.github.com/users/cweimann/gists{/gist_id}","starred_url":"https://api.github.com/users/cweimann/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cweimann/subscriptions","organizations_url":"https://api.github.com/users/cweimann/orgs","repos_url":"https://api.github.com/users/cweimann/repos","events_url":"https://api.github.com/users/cweimann/events{/privacy}","received_events_url":"https://api.github.com/users/cweimann/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2015-04-15T19:28:18Z","updated_at":"2015-04-15T19:28:18Z","closed_at":null,"body":"Specifying the tds_version is possible with \\_mssql.connect but not with pymssql.connect.  Since \\_mssql defaults to tds_version='7.1' there is no way to connect with any other version without calling \\_mssql.connect directly.  The tds version in freetds.conf seems to be ignored in all cases.  I'd say it is a very good thing to be able to connect without needing a freetds.conf but rejecting it altogether seems to be going to far.  I've patched local copy to allow specifying a tds_version in pymssql.connect and second to NOT default/force 7.1 in MSSQLConnection.__init__ but instead to allow specifying tds_vesion but allow the freetds.conf to take effect if it is not specified.\r\n\r\nI have seen a variety of other questions on the list that I think this is at the root of.  BTW the environment var TDSVER does work but other than that there is currently no way to escape tds_version 7.1.\r\n\r\n    diff --git a/_mssql.pyx b/_mssql.pyx\r\n    index 3572fcb..fc2fd4c 100644\r\n    --- a/_mssql.pyx\r\n    +++ b/_mssql.pyx\r\n    @@ -535,7 +535,7 @@ cdef class MSSQLConnection:\r\n             self.column_types = None\r\n\r\n         def __init__(self, server=\"localhost\", user=\"sa\", password=\"\",\r\n    -            charset='UTF-8', database='', appname=None, port='1433', tds_version='7.1', conn_properties=None):\r\n    +            charset='UTF-8', database='', appname=None, port='1433', tds_version=None, conn_properties=None):\r\n             log(\"_mssql.MSSQLConnection.__init__()\")\r\n\r\n             cdef LOGINREC *login\r\n    @@ -569,7 +569,8 @@ cdef class MSSQLConnection:\r\n             DBSETLUSER(login, user_cstr)\r\n             DBSETLPWD(login, password_cstr)\r\n             DBSETLAPP(login, appname_cstr)\r\n    -        DBSETLVERSION(login, _tds_ver_str_to_constant(tds_version))\r\n    +        if tds_version:\r\n    +            DBSETLVERSION(login, _tds_ver_str_to_constant(tds_version))\r\n\r\n             # add the port to the server string if it doesn't have one already and\r\n             # if we are not using an instance\r\n    diff --git a/pymssql.pyx b/pymssql.pyx\r\n    index 6ec4e7d..67c28b0 100644\r\n    --- a/pymssql.pyx\r\n    +++ b/pymssql.pyx\r\n    @@ -584,7 +584,7 @@ cdef class Cursor:\r\n\r\n     def connect(server='.', user='', password='', database='', timeout=0,\r\n             login_timeout=60, charset='UTF-8', as_dict=False,\r\n    -        host='', appname=None, port='1433', conn_properties=None, autocommit=False):\r\n    +        host='', appname=None, port='1433', tds_version=None, conn_properties=None, autocommit=False):\r\n         \"\"\"\r\n         Constructor for creating a connection to the database. Returns a\r\n         Connection object.\r\n    @@ -636,7 +636,7 @@ def connect(server='.', user='', password='', database='', timeout=0,\r\n         try:\r\n             conn = _mssql.connect(server=server, user=user, password=password,\r\n                                   charset=charset, database=database,\r\n    -                              appname=appname, port=port,\r\n    +                              appname=appname, port=port, tds_version=tds_version,\r\n                                   conn_properties=conn_properties)\r\n\r\n         except _mssql.MSSQLDatabaseException, e:\r\n"}}