Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adaptive Server Connection Failed on Windows pymssql >=2.2.8 #860

Closed
tbronson opened this issue Oct 28, 2023 · 2 comments
Closed

Adaptive Server Connection Failed on Windows pymssql >=2.2.8 #860

tbronson opened this issue Oct 28, 2023 · 2 comments

Comments

@tbronson
Copy link

SQL Server ver. 12.0.2000.8

with pymssql versions <= 2.2.7 this works fine

import pymssql
pymssql.connect(server="localhost")

using the local windows account authentication

however on pymssql versions >2.2.8 I get this instead:

Traceback (most recent call last):
  File "src\\pymssql\\_pymssql.pyx", line 647, in pymssql._pymssql.connect
  File "src\\pymssql\\_mssql.pyx", line 2109, in pymssql._mssql.connect
  File "src\\pymssql\\_mssql.pyx", line 701, in pymssql._mssql.MSSQLConnection.__init__
  File "src\\pymssql\\_mssql.pyx", line 1818, in pymssql._mssql.maybe_raise_MSSQLDatabaseException
  File "src\\pymssql\\_mssql.pyx", line 1835, in pymssql._mssql.raise_MSSQLDatabaseException
pymssql._mssql.MSSQLDatabaseException: (20002, b'DB-Lib error message 20002, severity 9:\nAdaptive Server connection failed (localhost)\nDB-Lib error message 20002, severity 9:\nAdaptive Server connection failed (localhost)\n')

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "src\\pymssql\\_pymssql.pyx", line 653, in pymssql._pymssql.connect
pymssql._pymssql.OperationalError: (20002, b'DB-Lib error message 20002, severity 9:\nAdaptive Server connection failed (localhost)\nDB-Lib error message 20002, severity 9:\nAdaptive Server connection failed (localhost)\n')
@tbronson
Copy link
Author

After some searching I solved the issue by setting tds_version to '7.0' as follows:

pymssql.connect(server="localhost", tds_version="7.0")

and everything works as normal again.

@Kyrie666
Copy link

Kyrie666 commented Jan 9, 2024

nice

@termim termim closed this as completed Apr 12, 2024
markus-leben added a commit to markus-leben/Robotframework-Database-Library that referenced this issue May 1, 2024
…Manager

Some database connection functions don't require all of dbapiModuleName, dbName, dbUsername...

These functions also fail in some libraries if given a blank string on some libraries. 

By 'some libraries' here I mostly mean pymssql, but these changes should be invisible to any tests running with a fully db.cfg. 

Similarly, I passed **kwargs in from connect_to_database on connections to misc databases not in the existing if/elif cases. This was mostly to allow for passing in tds_version on pymssql (see this issue: pymssql/pymssql#860), but it would be useful for any misc database to be able to set up their connection using custom parameters. 

It may also be a good idea to pass kwargs in to each db_connection in that whole big if/else statement, but I wanted this to be minimally impactful to connection modules I don't know well enough to not break.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants