title: Python to SQL Server Insert
body: <p>I'm trying to follow the method for inserting a Panda data frame into SQL Server that is mentioned <a href="https://iabdb.me/2016/07/13/a-better-way-load-data-into-microsoft-sql-server-from-pandas/comment-page-1/" rel="nofollow noreferrer">here</a> as it appears to be the fastest way to import lots of rows.</p>
  
  <p>However I am struggling with figuring out the connection parameter.
  I am not using DSN , I have a server name, a database name, and using trusted connection (i.e. windows login).</p>
  
  <pre><code>import sqlalchemy
  import urllib
  
  server = 'MYServer'
  db = 'MyDB'
  
  cxn_str = "DRIVER={SQL Server Native Client 11.0};SERVER=" + server +",1433;DATABASE="+db+";Trusted_Connection='Yes'"
  #cxn_str = "Trusted_Connection='Yes',Driver='{ODBC Driver 13 for SQL Server}',Server="+server+",Database="+db
  
  params = urllib.parse.quote_plus(cxn_str)
  engine = sqlalchemy.create_engine("mssql+pyodbc:///?odbc_connect=%s" % params)
  conn = engine.connect().connection
  cursor = conn.cursor()
  </code></pre>
  
  <p>I'm just not sure what the correct way to specify my connection string is. Any suggestions?</p>