pyodbc error on OS X machine?
Question: I'm trying to do access the remote MS-SQL database from my OS X machine, with
help of pyodbc and python. When I try to execute, it's showing an error like
this

    
    
    Error: ('IM002', '[IM002] [unixODBC][Driver Manager]Data source name not found, and no default driver specified (0) (SQLDriverConnect)')
    

The code I've written is:

    
    
    import pyodbc
    
    def createdatabase():
        driver = 'SQL Server'
        server = '00000000'
        db1 = 'Vodafone'
        tcon = 'yes'
        uname = 'user'
        pword = 'pwd'
    
        cnxn = pyodbc.connect(driver='{SQL Server}', host=server,database=db1,trusted_connection=tcon, user=uname, password=pword)
        cursor = cnxn.cursor()
    


Answer: This may not be your only problem, but the pyodbc.connect() string needs to be
formed with semicolons like this:

    
    
    DRIVER={FreeTDS};SERVER=yoursqlserver.com;PORT=1433;DATABASE=yourdb;UID=youruser;PWD=yourpass;TDS_Version=7.2;
    

You'll also have to read up on setting up FreeTDS and unixODBC from a Mac. If
you're specifying SQL Server instead of FreeTDS, I'm guessing you haven't set
up your configuration in freetds.conf, odbc.ini and odbcinst.ini, which are
required for connecting to SQL Server from non-Windows machines.

