title: Connect to Sybase data base using Python 3.6 and pymssql
body: <p>I am trying to connect to a Sybase database and retrieve data from it. I am working on a Ubuntu 18.04 system with the Anaconda repository installed and would like to use Python 3.6. </p>
  
  <p>I found a way to retrieve data from the DB with the python-sybase package, but this has dependencies on python 2.7 and is kind of outdated as far as I now.</p>
  
  <pre><code>import Sybase
  
  db = Sybase.connect(dsn = server:port, user = usr, passwd = pwd, database = db)
  c = db.cursor()
  c.execute("select var1,var2,var3 from xxx where datum=1yymmdd and statnr=stat1")
  list1 = c.fetchall()
  print list1
  </code></pre>
  
  <p>The Output of this script is something like this:</p>
  
  <pre><code>[(10.8, 100, 0), (11.2, 100, 5), (11.3, 100, 10), ..., ..., ...]
  </code></pre>
  
  <p>I tried to use te pymssql package instead, which is compatible to python 3.x.</p>
  
  <pre><code>import pymssql
  conn = pymssql.connect(server=serv:port,user=usr,password=pwd,database=db)
  print(conn)
  cursor = conn.cursor()
  cursor.execute("select var1,var2,var3 from xxx where datum=1yymmdd and statnr=stat1")
  list2 = cursor.fetchall()
  print(list2) 
  </code></pre>
  
  <p>But get the following error message, already after trying to connect to the Database, as it doesn't do print(conn): </p>
  
  <pre><code>Traceback (most recent call last):
  File "src/pymssql.pyx", line 636, in pymssql.connect
  File "src/_mssql.pyx", line 1957, in _mssql.connect
  File "src/_mssql.pyx", line 707, in _mssql.MSSQLConnection.__init__
  _mssql.MSSQLDriverException: Could not set connection properties
  
  During handling of the above exception, another exception occurred:
  
  Traceback (most recent call last):
  File "/home/progs/Test_SYBASE.py", line 9, in &lt;module&gt;
  conn =  pymssql.connect(server=serv,user=usr,password=pwd,database=db,port=prt)
  File "src/pymssql.pyx", line 645, in pymssql.connect
  pymssql.InterfaceError: Could not set connection properties
  </code></pre>
  
  <p>So my problem is actually concerning the connection itself. </p>
  
  <p>I read about the error message in the pymssql manual but don't know how to handle this.</p>
  
  <blockquote>
    <p>exception _mssql.MSSQLDriverException
    MSSQLDriverException is raised whenever there is a problem within _mssql – e.g. insufficient memory for data structures, and so on.</p>
    
    <p>exception pymssql.InterfaceError<br>
    Raised for errors that are related to the database interface rather than the database itself. A subclass of Error.</p>
  </blockquote>
  
  <p>Do you have any suggestion how to handle this? </p>
  
  <p>Thanks for help!</p>