Trap 6 Error connecting with PyODBC and wrong username or password
ValerioParisMitritsakis opened this issue · 4 comments
I am using MacOS Monterey 12.01, updated Homebrew to the latest of today, and I was getting a Trap 6 error upon execution of conn=pyodbc.connect(Driver). I then enabled SQL Tracing and found that there was a problem with the credentials. As soon as I replaced with the proper ones it worked like a charm.
However as it should not crash by a failed authentication I am adding the issue here including the trace file contents with sensitive information replaced for obvious reasons.
[ODBC][74949][1636450416.854237][__handles.c][460]
Exit:[SQL_SUCCESS]
Environment = 0x7fe785e06e00
[ODBC][74949][1636450416.854638][SQLSetEnvAttr.c][189]
Entry:
Environment = 0x7fe785e06e00
Attribute = SQL_ATTR_ODBC_VERSION
Value = 0x3
StrLen = 4
[ODBC][74949][1636450416.854841][SQLSetEnvAttr.c][381]
Exit:[SQL_SUCCESS]
[ODBC][74949][1636450416.855030][SQLAllocHandle.c][377]
Entry:
Handle Type = 2
Input Handle = 0x7fe785e06e00
UNICODE Using encoding ASCII 'UTF-8' and UNICODE 'UCS-2-INTERNAL'
[ODBC][74949][1636450416.855401][SQLAllocHandle.c][513]
Exit:[SQL_SUCCESS]
Output Handle = 0x7fe785e3d600
[ODBC][74949][1636450416.857144][SQLDriverConnectW.c][290]
Entry:
Connection = 0x7fe785e3d600
Window Hdl = 0x0
Str In = [DRIVER={ODBC Driver 17 for SQL Server};SERVER=10.xxx.yyy.zzz,1433;DATABASE=DBNAME;UID=UserName;PWD=][length = 108 (SQL_NTS)]
Str Out = 0x0
Str Out Max = 0
Str Out Ptr = 0x0
Completion = 0
[ODBC][74949][1636450417.043445][__handles.c][460]
Exit:[SQL_SUCCESS]
Environment = 0x7fe785e3c600
[ODBC][74949][1636450417.044276][SQLGetEnvAttr.c][157]
Entry:
Environment = 0x7fe785e3c600
Attribute = 65002
Value = 0x7ff7bdfa82b0
Buffer Len = 128
StrLen = 0x7ff7bdfa8294
[ODBC][74949][1636450417.044441][SQLGetEnvAttr.c][273]
Exit:[SQL_SUCCESS]
[ODBC][74949][1636450417.044596][SQLFreeHandle.c][220]
Entry:
Handle Type = 1
Input Handle = 0x7fe785e3c600
[ODBC][74949][1636450417.046198][SQLDriverConnectW.c][699]
Exit:[SQL_ERROR]
[ODBC][74949][1636450417.046368][SQLDriverConnect.c][748]
Entry:
Connection = 0x7fe785e3d600
Window Hdl = 0x0
Str In = [DRIVER={ODBC Driver 17 for SQL Server};SERVER=10.xxx.yyy.zzz,1433;DATABASE=DBNAME;UID=UserName;PWD=][length = 108 (SQL_NTS)]
Str Out = 0x7ff7bdfa8c70
Str Out Max = 2048
Str Out Ptr = 0x0
Completion = 0
DIAG [28000] [Microsoft][ODBC Driver 17 for SQL Server][SQL Server]Login failed for user 'UserName'.
DIAG [42000] [Microsoft][ODBC Driver 17 for SQL Server][SQL Server]Cannot open database "DBNAME" requested by the login. The login failed.
Do you see the same problem if you just connect using isql -v -k 'your connection string here'
?
Note that macOS 12 is not supported (yet).
I've just tested it and yes, it also gives me a Trap 6. Just for the fun of it I've also replaced the DB with a non existent one while keeping the correct credentials and it still crashed the same way. So it's probably not a credentials related problem.
Unable to reproduce this even with macOS 12. After installing driver 17.8 (and OpenSSL workaround noted in #59) neither successful nor unsuccessful connection crashes.
Closing due to inactivity. Reopen if you can reproduce this on a clean machine and can describe the steps to do so.