title: Sqlalchemy - Connecting to Microsoft Azure - Active directory Password
body: <p>I was connecting to MS SQL with sqlalchemy using bwlow code and now it has been migrated to azure cloud. I tried the chaging the values code but i think its not the proper way to connect ActiveDirectoryPassword   </p>
  
  <pre><code>    import sqlalchemy
          from sqlalchemy import event, create_engine
  # OLD connection string 
          engine = sqlalchemy.create_engine("mssql+pyodbc://" + "username" + ":" + "passkey" + "@" + "server" + "/" + "Database" + "?driver=SQL+Server"
  
          @event.listens_for(engine, 'before_cursor_execute')
          def receive_before_cursor_execute(conn, cursor, statement, params, context, executemany):
              if executemany:
                  cursor.fast_executemany = True
                  cursor.commit()
  
      # New connection string (for Active directory connection - not working)
      engine = sqlalchemy.create_engine("mssql+pyodbc://" + "abc@domain.com" + ":" + "passkey" + "@" + "xxxx-svsql1.database.windows.net" + "/" + "Database" + "?driver=SQL+Server" + "Authentication=ActiveDirectoryPassword")
  </code></pre>
  
  <p>Please note I was able to successfully able to connect using pyodbc but not able to do that using sqlalchemy by following</p>
  
  <p><a href="https://stackoverflow.com/questions/40118470/cannot-connect-to-sql-server-from-python-using-active-directory-authentication/44076936#44076936">enter link description here</a></p>
  
  <p>Please guide </p>