I'm trying to establish a jTDS connectivity using Python. Can anyone please help me in accomplishing that?
From the SQL Server, I generally connect using the below connection string:
jdbc:jtds:sqlserver://DBServer:port/DBInstance;useNTLMv2=true;domain=Domain
I'm trying to do as below in Python:
import pyodbc
conn = pyodbc.connect('Driver={SQL Server};'
'Server=DBName,port;'
'Database=database;'
'Truster_Connection=yes;'
'uid=user;'
'pwd=password;'
)
cursor = conn.cursor()
cursor.execute('SELECT * from Table')
for row in cursor:
print(row)
Error:
pyodbc.InterfaceError: ('28000', "[28000] [Microsoft][ODBC SQL Server Driver][SQL Server]Login failed for user 'USER'. (18456) (SQLDriverConnect); [28000] [Microsoft][ODBC SQL Server Driver]Invalid connection string attribute (0); [28000] [Microsoft][ODBC SQL Server Driver][SQL Server]Login failed for user 'USER'. (18456); [28000] [Microsoft][ODBC SQL Server Driver]Invalid connection string attribute (0)"))