0
votes

I am trying to connect to a SQL Server database with Python using this code:

conn = pyodbc.connect(
                  r'Driver={SQL Server Native Client 11.0};'    
                  r'Server=12345.dcd_ba.weatherton.com;'
                  r'Database=Dentrix;'
                  r'Trusted_Connection=no;'
                  r'Integrated security=false;'
                  r'username=fred;'
                  r'password=test;'
                 )
return conn

But I am getting this error:

pyodbc.InterfaceError: ('28000', "[28000] [Microsoft][SQL Server Native Client 11.0][SQL Server]Login failed for user ''. (18456) (SQLDriverConnect); [28000] [Microsoft][SQL Server Native Client 11.0]Invalid connection string attribute (0); [28000] [Microsoft][SQL Server Native Client 11.0][SQL Server]Login failed for user ''. (18456); [28000] [Microsoft][SQL Server Native Client 11.0]Invalid connection string attribute (0)")

1
FYI, a trusted connection, and integrated security are the same thing; there's no point declaring both. - Larnu

1 Answers

1
votes

According to Using Connection String Keywords with SQL Server Native Client it looks like you need to use UID instead of username