title: Unable to connect to server with python and pymssql
body: <p>I'm developing a script that it's supossed to read data from a Microsoft SQL database and display it in a nice format. Also, It's supossed to write into the database as well. The issue is that I'm not able to connect to the server.</p>
  
  <p>I'm using this code:</p>
  
  <pre><code>import pymssql
  
  server = "serverIpAddress"
  user = "username"
  password =  "pass"
  db = "databaseName"
  
  port = 1433
  db = pymssql.connect(server,user,password,port= port)
  
  # prepare a cursor object using cursor() method
  cursor = db.cursor()
  
  # execute SQL query using execute() method.
  cursor.execute("SELECT VERSION()")
  
  # Fetch a single row using fetchone() method.
  data = cursor.fetchone()
  
  print "Database version : %s " % data
  
  # disconnect from server
  db.close()
  </code></pre>
  
  <p>And I'm getting this traceback:</p>
  
  <pre><code>Traceback (most recent call last):
    File ".\dbtest.py", line 9, in &lt;module&gt;
      db = pymssql.connect(server,user,password,port= port)
    File "pymssql.pyx", line 641, in pymssql.connect (pymssql.c:10824)
  pymssql.OperationalError: (18452, 'Login failed. The login is from an untrusted domain and cannot be used with Windows authentication.DB-Lib error message 20018, severity 14:\nGeneral SQL Server e
  rror: Check messages from the SQL Server\nDB-Lib error message 20002, severity 9:\nAdaptive Server connection failed (serverip:1433)\n')
  </code></pre>
  
  <p>I've changed some data to keep privacy.</p>
  
  <p>This give me some clues about what it's going on:</p>
  
  <pre><code>The login is from an untrusted domain and cannot be used with Windows authentication
  </code></pre>
  
  <p>But I don't know how to fix it. I've seen that some people uses </p>
  
  <pre><code>integratedSecurity=true
  </code></pre>
  
  <p>But I don't know if there is something like this on pymssql or even if that it's a good idea.</p>
  
  <p>Also, I don't need to use pymssql at all. If you know any other library that can perform what I need, I don't mind changing it.</p>
  
  <p>Thanks and greetings.</p>
  
  <p>--EDIT--</p>
  
  <p>I've also tested this code:</p>
  
  <pre><code>import pyodbc
  
  server = "serverIpAddress"
  user = "username"
  password =  "pass"
  db = "databaseName"
  
  
  connectString = "Driver={SQL Server};server="+serverIP+";database="+db+";uid="+user+";pwd="+password
  con = pyodbc.connect(connectString)
  cur = con.cursor()
  cur.close()
  con.close()
  </code></pre>
  
  <p>and I'm getting this traceback:</p>
  
  <pre><code>Traceback (most recent call last):
    File ".\pyodbc_test.py", line 9, in &lt;module&gt;
      con = pyodbc.connect(connectString)
  pyodbc.Error: ('28000', "[28000] [Microsoft][ODBC SQL Server Driver][SQL Server]Login failed for user '.\\sa'. (18456) (SQLDriverConnect); [28000] [Microsoft][ODBC SQL Server Driver][SQL Server]Lo
  gin failed for user '.\\sa'. (18456)")
  </code></pre>