1

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. Commented Jan 26, 2021 at 19:14

1 Answer 1

1

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

Sign up to request clarification or add additional context in comments.

1 Comment

you are right @DavidBrowne-Microsoft I clarified my answer

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.