python pyodbc - connecting to sql server 2008 on windows/python2.7 but not on centOS6.32/python2.6.6
Question: I have the following code:

    
    
    import pyodbc
    
    cnxn = pyodbc.connect("DRIVER={SQL Server};"
                          +"SERVER=something.example.com;"
                          +"DATABASE=something;")
    
    cursor = cnxn.cursor()
    
    name=('Smith, Joe', )
    
    cursor.execute('SELECT id FROM Users WHERE displayname=?', name)
    rows = cursor.fetchall()
    
    for row in rows:
            print row
    

The code executes as desired on windows/python2.7. However, when I try to run
it on linux, I get the following error:

    
    
    Traceback (most recent call last):
      File "/something/script.py", line 125, in <module>
        main()
      File "/something/script.py", line 77, in main
        +"DATABASE=something;")
    pyodbc.Error: ('IM002', '[IM002] [unixODBC][Driver Manager]Data source name not found, and no default driver specified (0) (SQLDriverConnectW)')
    

The traceback seems to indicate that the `DRIVER` entry is missing, which
isn't the case. Is this a version difference? What is the issue with pyodbc?

EDIT: contents of /etc/odbcinst.ini:

    
    
    # Example driver definitions
    
    # Driver from the postgresql-odbc package
    # Setup from the unixODBC package
    [PostgreSQL]
    Description     = ODBC for PostgreSQL
    Driver          = /usr/lib/psqlodbc.so
    Setup           = /usr/lib/libodbcpsqlS.so
    Driver64        = /usr/lib64/psqlodbc.so
    Setup64         = /usr/lib64/libodbcpsqlS.so
    FileUsage       = 1
    
    
    # Driver from the mysql-connector-odbc package
    # Setup from the unixODBC package
    [MySQL]
    Description     = ODBC for MySQL
    Driver          = /usr/lib/libmyodbc5.so
    Setup           = /usr/lib/libodbcmyS.so
    Driver64        = /usr/lib64/libmyodbc5.so
    Setup64         = /usr/lib64/libodbcmyS.so
    FileUsage       = 1
    


Answer: You don't have an odbc driver for sql server configured - you need to install
and configure one. The drivers section on
[unixodbc](http://www.unixodbc.org/drivers.html)'s webpage suggests
[freetds](http://www.freetds.org/), alternatively you could also try
microsoft's own [implementation](http://technet.microsoft.com/en-
us/library/hh568451.aspx).

freedts should be installable using `yum`.

The basic configuration then should look something like this:

`/etc/odbcinst.ini`:

    
    
    [SQL Server]
    Description = FreeTDS driver for SQL Server
    Driver = /usr/lib/libtdsodbc.so
    Driver64 = /usr/lib64/libtdsodbc.so
    

Now you should already be able to connect. For more detailled information on
configuration, look [here](http://www.freetds.org/userguide/).

edit:

alternatively there are also other ways to connect to an sql server from
python, like [python-tds](https://pypi.python.org/pypi/python-tds),
[pymssql](https://pypi.python.org/pypi/pymssql) and
[more...](http://wiki.python.org/moin/SQL%20Server)

