Question

I am setting up Go, FreeTDS, and unixODBC on OSX. I followed the instructions on https://code.google.com/p/odbc/wiki/InstallingUnixODBCOnOSX, and when I tried to run the tests, I get:

[ODBC Driver Manager] Data source name not found and no default driver specified

The port installs both unixODBC and FreeTDS, so what is needed to resolve this problem?

Was it helpful?

Solution 2

In Linux you use odbcinst to register the data source, but you need to know where libtdsodbc.so is

On my Mac, it was put in

/opt/local/lib/libtdsodbc.so

If that's not where yours was installed, do this to find its location:

sudo find / -name "libtdsodbc.so"

Then create a file called "tds.driver.template" with the following inside:

[FreeTDS]
Description = Open source FreeTDS Driver
Driver =/opt/local/lib/libtdsodbc.so

Then run

sudo odbcinst -i -d -f tds.driver.template

OTHER TIPS

In my opinion, the best way to do is to use a DSN-less configuration — when you encode full information required to connect to a server instance in the ODBC connection string. The upside of this approach is that it requires exactly zero configuration of the client machine, other than making sure the FreeTDS ODBC driver is properly installed.

Note two caveats applicable to FreeTDS in this sort of setup though:

  • You have to use the Port connection string key. It's typically 1433 if you're connecting to a Microsoft® SQL Server™.
  • FreeTDS has an insanely low default TDS protocol version — something like 5.0.

    To override this, you have to use the TDS_Version connection string key. Either set it to auto or to a some sensible value:

    • Microsoft® SQL Server™ 7.0 → 7.0
    • 〃 2000 → 7.1
    • 〃 2005 → 7.2
    • 〃 2008 → 7.3
    • 〃 2012 → 7.4

    Looks like 7.2 is the largest TDS protocol version currently supported by FreeTDS but actually 7.2 is more than enough to work with typical data types, including varbinary(max).

I was running into this issue, and I think what fixed it was setting the ODBCSYSINI and ODBCINI environment variables (credit to this answer). For Mac, you need to set them to these values:

export ODBCSYSINI=/Library/ODBC
export ODBCINI=/Library/ODBC/odbc.ini
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top