question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Invalid connection string attribute

See original GitHub issue

Environment

To diagnose, we usually need to know the following, including version numbers. On Windows, be sure to specify 32-bit Python or 64-bit:

  • Python: Python 3.5.2
  • pyodbc: 4.0.25
  • OS: Ubuntu:16.04
  • DB: Microsoft SQL Server 2016 (SP1-CU8) (KB4077064) - 13.0.4474.0 (X64)
  • driver: ODBC Driver 13 for SQL Server

Issue

DB admin asked me about failed login message in db, like “Logon,Unknown,Login failed for user ‘user’. Reason: Password did not match that for the login provided. [CLIENT: 127.0.0.1]”. But there are no any exceptions in the service which works with this db. I turned on ODBC trace mode and discovered the situation like this:

                Entry:
                        Connection = 0x2f8e930
                        Window Hdl = (nil)
                        Str In = [DRIVER={ODBC Driver 13 for SQL Server};SERVER=127.0.0.1;PORT=1433;DATABASE=dbname;UID=user;PWD=pwd][length = 108 (SQL_NTS)]
                        Str Out = (nil)
                        Str Out Max = 0
                        Str Out Ptr = (nil)
                        Completion = 0
                UNICODE Using encoding ASCII 'ISO8859-1' and UNICODE 'UCS-2LE'

[ODBC][1464][1547213406.545475][SQLDriverConnectW.c][699]
                Exit:[SQL_ERROR]
[ODBC][1464][1547213406.545520][SQLDriverConnect.c][726]
                Entry:
                        Connection = 0x2f8e930
                        Window Hdl = (nil)
                        Str In = [DRIVER={ODBC Driver 13 for SQL Server};SERVER=127.0.0.1;PORT=1433;DATABASE=dbname;UID=user;PWD=*********][length = 107 (SQL_NTS)]
                        Str Out = 0x7ffda0246350
                        Str Out Max = 2048
                        Str Out Ptr = (nil)
                        Completion = 0
                UNICODE Using encoding ASCII 'ISO8859-1' and UNICODE 'UCS-2LE'
                DIAG [01000] [Microsoft][ODBC Driver 13 for SQL Server][SQL Server]Changed database context to 'dbname'.
                DIAG [01000] [Microsoft][ODBC Driver 13 for SQL Server][SQL Server]Changed language setting to us_english.
                DIAG [01S00] [Microsoft][ODBC Driver 13 for SQL Server]Invalid connection string attribute

ODBC repeats the action several times and after success continues to work. The connection string itself is valid and the problem is hardly reproduced, once in several thousand connections.

After rolled back on pyodbc==4.0.24 problem was solved.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:1
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
gordthompsoncommented, Jan 16, 2019

Microsoft’s ODBC Drivers for SQL Server do not support a PORT= attribute. Instead, the port number, if any, needs to be appended to the server name/IP with a comma. That is …

… not this …

SERVER=192.168.0.188;PORT=45678

… but this …

SERVER=192.168.0.188,45678

That might very well be the source of the “Invalid connection string attribute” warning.

0reactions
keitherskinecommented, May 29, 2021

Closed due to inactivity. Feel free to re-open with current information if necessary.

Read more comments on GitHub >

github_iconTop Results From Across the Web

SQL Server connection string - Microsoft Q&A
I am unable to connect SQL Server database from my Julia Language code web server; I suspect I am not able to figure...
Read more >
Error: -2147217843: Invalid connection string attribute
This occurs when the computer name or IP address changes. The Global connection updates, but the entity's connection (inside the Papervision ...
Read more >
Cannot connect to SharePoint database due to invalid ...
"Invalid connection string attribute" appears in the installation log even if the connection string is valid. Product/Version includes:View More.
Read more >
Thread: [RESOLVED] Invalid Connection String Attribute
If you need to solve that error, you can find Services in Control Panel - Admin Tools. In terms of the error "Invalid...
Read more >
Error "Invalid connection string attribute" when test ...
Error "Invalid connection string attribute" when test data_engine probe connection to database · Article ID: 134910. calendar_today · Updated On: 10-01-2022 ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found