1

I am using SQLalchemy with pyodbc to connect to a SQL server. I can connect using "Windows Authentication":

create_engine('mssql+pyodbc://[ServerName]/[DatabaseName]',echo=True)

That is fine but when I try to login (SQL server authentication) it fails:

create_engine('mssql+pyodbc://[User]:{Password]@[ServerName]/[DatabaseName]',echo=True)
  1. Is my code correct? Am I missing a setting?
  2. Is there a way of listing database users to check the names?
1
  • Please provide the error message received when using SQL Server auth, will give us a better idea of what is needed to resolve. Commented Jun 4, 2012 at 17:51

1 Answer 1

1
  1. Yes, your connection string is correct. Make sure the user/pwd combinations are correct. Also note that user/pwd can only be used for users which use "SQL Server authentication" (in the code below SQL_LOGIN) and not "Windows authentication"
  2. Given you connect with enough permissions, you can execute the following to see all logins:
    for x in session.execute("SELECT name, type, type_desc FROM sys.server_principals"): print x
Sign up to request clarification or add additional context in comments.

Comments

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.