Add an option to use Windows Authentication (trusted connections) when connecting to MS SQL Server databases, as an alternative to SQL Server Authentication with username/password.
Windows Authentication allows users to connect to SQL Server using their Windows/Active Directory credentials without specifying a username and password in the connection string. This is the preferred authentication method in many enterprise environments because:
- No credentials stored in connection strings or environment variables
- Centralized access management through Active Directory
- Better audit trails and compliance
- Support for Kerberos delegation
Proposed Implementation
In SQLAlchemy, trusted connections are enabled by adding trusted_connection=yes to the connection URL or using Integrated Security=SSPI:
# Option 1: Using the trusted_connection parameter
engine = create_engine(
"mssql+pyodbc://myserver/mydb?driver=ODBC+Driver+17+for+SQL+Server&trusted_connection=yes"
)
# Option 2: Using Integrated Security
engine = create_engine(
"mssql+pyodbc://myserver/mydb?driver=ODBC+Driver+17+for+SQL+Server&Integrated_Security=SSPI"
)
Add an option to use Windows Authentication (trusted connections) when connecting to MS SQL Server databases, as an alternative to SQL Server Authentication with username/password.
Windows Authentication allows users to connect to SQL Server using their Windows/Active Directory credentials without specifying a username and password in the connection string. This is the preferred authentication method in many enterprise environments because:
Proposed Implementation
In SQLAlchemy, trusted connections are enabled by adding
trusted_connection=yesto the connection URL or usingIntegrated Security=SSPI: