title: pyodbc connection to MSSQL
body: <p>I find difficulties in the connection of pyodbc with SQL server. After reading all the questions and references, I still could not find an answer about how to deal with this error:</p>
  
  <blockquote>
    <p>Error: ('08001', '[08001] [Microsoft][ODBC SQL Server Driver][DBNETLIB]SQL >Server does not exist or access denied. (17) (SQLDriverConnect); [01000] >[Microsoft][ODBC SQL Server Driver][DBNETLIB]ConnectionOpen (Connect()). (53)')</p>
  </blockquote>
  
  <p>My code is shown below:</p>
  
  <pre><code>import pyodbc
  cnxn = pyodbc.connect(driver='{SQL Server}',server = 'SQLOLEDB',
  database =    'K2DS1')
  cursor = cnxn.cursor()
  cursor.execute("select*from stocks")
  for row in cursor.fetchall():
      print row
  </code></pre>
  
  <p>Thanks,</p>