In order to use Windows Authentication with sqlalchemy and mssql, the following connection string is required:
ODBC Driver:
engine = sqlalchemy.create_engine('mssql://*server_name*/*database_name*?trusted_connection=yes')
SQL Express Instance:
engine = sqlalchemy.create_engine('mssql://*server_name*\\SQLEXPRESS/*database_name*?trusted_connection=yes')
UPDATE:
@DoloMike noticed that the previously provided solution is outdated and may not work as expected. Here’s the corrected solution based on his comment below:
engine = create_engine('mssql+pyodbc://@' + servername + "https://stackoverflow.com/" + dbname + '?trusted_connection=yes&driver=ODBC+Driver+13+for+SQL+Server')
Adjust the ODBC Driver version based on your installed sql server.