title: pyodbc not working on RedHat 5.4. Trying to connect to ms-sql database server using unixODBC and FreeTDS?
body: <p>I am facing issue while trying to access ms-sql database using pyobdc.</p>
  
  <p><strong>Here is the System config:</strong>
  Python 2.7.11
  Pyodbc 3.0.7
  RedHat 5.4 (Tikanga) 32 Bit system
  Microsoft SQL Server 2012 (Database server)
  unixODBC 2.3.0</p>
  
  <p><strong>$ <code>tsql -C</code> output :</strong></p>
  
  <pre><code>Compile-time settings (established with the "configure" script)
                              Version: freetds v0.91
               freetds.conf directory: /etc
       MS db-lib source compatibility: yes
          Sybase binary compatibility: no
                        Thread safety: yes
                        iconv library: yes
                          TDS version: 5.0
                                iODBC: no
                             unixodbc: yes
                SSPI "trusted" logins: no
                             Kerberos: no
  </code></pre>
  
  <p><strong>$ <code>odbcinst -j</code> output :</strong></p>
  
  <pre><code>unixODBC 2.3.0
  DRIVERS............: /usr/local/etc/odbcinst.ini 
  SYSTEM DATA SOURCES: /usr/local/etc/odbc.ini
  FILE DATA SOURCES..: /usr/local/etc/ODBCDataSources
  USER DATA SOURCES..: /root/.odbc.ini
  SQLULEN Size.......: 4
  SQLLEN Size........: 4
  SQLSETPOSIROW Size.: 2
  </code></pre>
  
  <p><strong>$ <code>cat /usr/local/etc/odbcinst.ini</code> output :</strong></p>
  
  <pre><code>[ms-sql]
  Description=TDS connection
  Driver=/usr/local/lib/libtdsodbc.so
  Setup=/usr/local/lib/libtdsodbc.so
  FileUsage=1
  UsageCount=1
  </code></pre>
  
  <p><strong>$ <code>cat /usr/local/etc/odbc.ini</code> output :</strong></p>
  
  <pre><code>[sqlserverdatasource]
  Driver = ms-sql
  Description = ODBC connection via ms-sql
  Trace = No
  Server = &gt;IP Addresss To Database server&lt;
  Port = &gt;Port Number&lt;
  Database = &gt;Database name&lt;
  </code></pre>
  
  <p><strong>$ <code>cat /etc/freetds.conf</code> output :</strong></p>
  
  <pre><code>[sql-server]
  host        = &gt;IP Addresss To Database server&lt;
  port        = &gt;Port Number&lt;
  tds version = 8.0
  </code></pre>
  
  <p><strong><em>Command which is giving me error:</em></strong></p>
  
  <pre><code>connection = pyodbc.connect(r'DRIVER={FreeTDS};SERVER=&gt;IP Addresss To Database server&lt;; PORT=&gt;Port Number&lt;;DATABASE=Database name;UID=Database UID;PWD=DatabasePasswd;')
  </code></pre>
  
  <p><strong><em>Error:</em></strong> </p>
  
  <pre><code>Traceback (most recent call last):   File "&lt;stdin&gt;", line 1, in
  &lt;module&gt; pyodbc.Error: ('IM002', '[IM002] [unixODBC][Driver
  Manager]Data source name not found, and no default driver specified
  (0) (SQLDriverConnect)')
  </code></pre>
  
  <p>I am trying to solve this problem for last 3 days. But no luck yet. So any help/suggestion would be very helpful.
  I have already gone through googling.
  Thanks in advance :)</p>