mkleehammer / pyodbc

Python ODBC bridge
https://github.com/mkleehammer/pyodbc/wiki
MIT No Attribution
2.95k stars 563 forks source link

[SAP][ODBC Driver][SQL Anywhere]Invalid user ID or password (-103) (SQLDriverConnect) #1173

Closed AndreiLetyushov closed 1 year ago

AndreiLetyushov commented 1 year ago

Environment

Issue

After SQL Anywhere server was updated to 17.0.10.5963 version, python application get error about wrong user id or password. Tried from MacOS, linux, Windows. The same error on the all platforms.

But SQL Central(Windows version) with the same credentials works perfect, connects to server without problem.

v-chojas commented 1 year ago

This has nothing to do with pyODBC. Please contact your DBMS vendor instead.

gordthompson commented 1 year ago

Use the Windows ODBC Administrator (odbcad32.exe) to create a System DSN for your database, and use the "Test Connection" button to verify that the DSN is configured correctly. Then try

import pyodbc

cnxn = pyodbc.connect("DSN=your_dsn;UID=your_username;PWD=your_password")
print("Connected.")

If that fails, then it is a pyodbc issue. Otherwise, you have some other problem.

SmallGreenHedgehog commented 1 year ago

Good day for you! I have the same issue.

When i try to connect to the database, i get the following error: "Error ('28000', '[28000] [SAP][ODBC Driver][SQL Anywhere]Invalid user ID or password (-103) (SQLDriverConnect); [28000] [SAP][ODBC Driver][SQL Anywhere]Invalid user ID or password (-103)')"

Code:

import pyodbc

if __name__ == '__main__':
    try:
        connection = pyodbc.connect('DSN=TEST;UID=dba;PWD=sql;')
    except Exception as e:
        print(f'Error {e}')
SmallGreenHedgehog commented 1 year ago

image

v-chojas commented 1 year ago

It was the server that changed to cause this problem, and not pyODBC, so you should talk to your DBMS vendor about this. pyODBC is just a passthrough.

gordthompson commented 1 year ago

@SmallGreenHedgehog - Was your test (above) run from a Windows machine?

SmallGreenHedgehog commented 1 year ago

Yes. It was Windows 11

gordthompson commented 1 year ago

Yes. It was Windows 11

Okay, thanks. Please save the following code to a file named odbc_test.vbs

' odbc_test.vbs
Set conn = CreateObject("ADODB.Connection")
conn.Open "DSN=TEST;UID=dba;PWD=sql;"
WScript.Echo "Connected."

… and try running it from a command prompt with

cscript odbc_test.vbs

Does it give the same error?

SmallGreenHedgehog commented 1 year ago

Unfortunately yes. The same error.

Microsoft OLE DB Provider for ODBC Drivers: [SAP][ODBC Driver][SQL Anywhere]Invalid user ID or password

Thank you for answers.

gordthompson commented 1 year ago

OK so this is not a pyodbc issue per se, because the VBScript also fails and it doesn't use pyodbc.

As @v-chojas suggests, you'll need to reach out to the SQL Anywhere community and ask about what might have broken ODBC functionality in a recent release of SQL Anywhere.

And BTW, I just tried to get an ODBC trace when I click the "Test Connection" button in the ODBC Data Source Administrator. I got the "Connection successful" message but no trace file was created, so whatever the "Test Connection" button is doing it's apparently not going through the ODBC Driver Manager.