0

I was looking at the documentation listed sqlalchemy engine interface dialect and I can't see where it says how to do this.

I know I need to use trusted_connection = 'yes' but I want to know where it says that that is what we need to do.

Can someone point me in the correct direction?

1 Answers1

1

I figured it out.

What to do:

1) Use the DBAPI to connect to the database, in my case, it is pyodbc.

2) The connection string you will pass will be based upon the driver being used, in my case, ODBC Driver 11 for SQL Server.

3) In the syntax used for my driver, it specifically says to use trusted_connection='yes' for windows authentication.

4) The values you need to pass to create_engine are the same values you would send to the driver you are using.

Details:

1) What I am doing:

I am using pyodbc to access SQL Server. I am then using sqlalchemy to work with the database.

2) Trusted_connection = 'yes' is not found on the documentation for SQLAlchemy because it is part of the connection string, not the syntax for create_engine.

3) Documentation for pyodbc and Connection Strings. Pyodbc does not look at the connection string. The connection string is passed to the databse driver unmodified and is driver-specific. Documentation for Connecting to databases

4) Reference for all connection strings can tell you specifically what the connection string needs to look like for each database you are trying to connect to.

5) Not part of my original question, but was curious about this too: Port number is only required if connecting outside of the network SQL Server is on. When is Port Number Required

6) In the create engine documentation it says that the URL is the first positional argument, but when you look at the parameters, it does not specify this. I'd love for someone to prove me wrong, but I'm convinced this is true.