Cannot connect to SQL server from python using Active Directory Authentication
<p>I am using pymssql library to connect python to Sql Server. I can connect using windows/sql server authentication. I want to connect using Active Directory Authentication. </p>

<p>Tried the below connection string. But it fails with error : </p>

<pre><code>unexpected keyword authentication


conn = pymssql.connect(server='adventureworks.database.windows.net', authentication = 'Active Directory Password',user='username@server.com',password='Enterpasswordhere', database='dbo')
</code></pre>

<p><a href="http://pymssql.org/en/latest/ref/pymssql.html#functions" rel="nofollow">Note that pymssql.connect does not have an 'authentication' parameter</a>. You are passing it that as a named arg, which is invalid, and the reason you see your error.</p>

<p>See <a href="http://pymssql.org/en/latest/pymssql_examples.html#connecting-using-windows-authentication" rel="nofollow">this example</a> for connecting using windows authentication:</p>

<pre><code>conn = pymssql.connect(
    host=r'dbhostname\myinstance',
    user=r'companydomain\username',
    password=PASSWORD,
    database='DatabaseOfInterest'
)
</code></pre>

python sql-server