[freetds] How does one actually *use* FreeTDS?

Merle Reinhart merlereinhart at mac.com
Sat Apr 11 14:18:31 EDT 2009


Michael,

I use FreeTDS to talk to both Sybase and MS SQL Servers from Mac OS  
10.5.6 at work.

I don't use unixODBC since iODBC comes installed with the Mac OS, so  
my examples below assume iODBC was used when compiling FreeTDS. Also,  
I build FreeTDS myself and installed it in /usr/local/freetds/ so  
adjust accordingly.

I pretty much just followed what is described in the freetds user  
guide using the ODBC-combined configuration since I want to use sqsh  
(or fisql) and ODBC to talk to the servers duplicating as little of  
the details of the servers as possible between the two sets of  
configuration files.

Here is an example from my freetds.conf file.  The Sybase server in  
this example is 'bob' and the MS SQL server is 'fred'.  The Sybase  
servers far out number and were in existence prior to the MS SQL  
server, so that is why the tds version 5 is specified in the [global]  
section.  The other thing is I use my local DNS server to resolve the  
hostname rather than hardcode IP-addresses into the file.


freetds.conf:

[global]
         # TDS protocol version
         tds version = 5.0

[BOB]
         host = bob.domain.com
         port = 9002

[FRED]
         host = fred.domain.com
         port = 1433
         tds version = 8.0



That will let me connect to the servers via sqsh or fisql.  Now to  
setup the ODBC configuration files.

iODBC on the Mac expects to see the configuration files in /Library/ 
ODBC for system-wide configurations and ~/Library/ODBC for user  
configurations.  I use the system-wide configurations so all the users  
on that Mac can connect to the servers.  Normally, the ODBC driver  
installer package is expected to create the appropriate odbcinst.ini  
file.  Once that is done, the /Applications/Utilities/ODBC  
Administrator can be used to setup the database connections.  However,  
freetds doesn't include a Mac OS X native installer for the ODBC  
driver so the file must be created by hand with a text editor.

So, create the /Library/ODBC directory if is doesn't exist.

My odbcinst.ini file for freetds is:

;
; odbcinst.ini
;
[ODBC Drivers]
FreeTDS = Installed


[FreeTDS]
Driver = /usr/local/freetds/lib/libtdsodbc.so



You an use the ODBC Administrator app to create the odbc entries, but  
I just used a text editor.  The file goes in /Library/ODBC and is  
called odbc.ini:

[ODBC Data Sources]
BOB         = FreeTDS
FRED        = FreeTDS

[BOB]
Driver      = /usr/local/freetds/lib/libtdsodbc.so
Description = BOB Sybase Server
Servername  = BOB

[FRED]
Driver      = /usr/local/freetds/lib/libtdsodbc.so
Description = Fred MS SQL Server
Servername  = FRED

[Default]
Driver      = /usr/local/freetds/lib/libtdsodbc.so



That's it.  You should now be able to see the entries in the ODBC  
Administrator GUI tool.

This has worked for me for several years now with several Sybase  
servers and in the past year with a MS SQL Server.


All this was figured out by just going through the freetds userguide  
and a little playing.  The 'Servername' in the ODBC file must match  
the freetds.conf entry since I'm using the ODBC-combined  
configuration.  That's the only thing I can think of to watch out for.


Merle





On Apr 11, 2009, at 1:20 PM, freetds-request at lists.ibiblio.org wrote:

> Message: 1
> Date: Sat, 11 Apr 2009 10:54:21 -0400
> From: "lists at mgreg.com" <lists at mgreg.com>
> Subject: [freetds] How does one actually *use* FreeTDS?
> To: freetds at lists.ibiblio.org
> Message-ID: <0C3CDB08-A0A9-48E0-8B82-24D410493725 at mgreg.com>
> Content-Type: text/plain; charset=US-ASCII; format=flowed; delsp=yes
>
> Hi All,
>
> I'm a bit confused as to how to actually go about using the FreeTDS
> library.  My ultimate goal is to be able to use it as my means of
> contact with MS SQL Server from Mac OS 10.5.6.  I see all kinds of
> documentation regarding installation, but very little about actual use
> cases.
>
> Perhaps I have the wrong thing in mind, but I'm looking to use the
> ODBC Administrator to set up a DSN and take it from there.  I also
> have unixODBC installed, but am not quite sure if what I'm looking for
> is directly possible?
>
> FYI, I've installed FreeTDS via Macports and have done no manual
> configuration, but I'm more than happy to go back and manually install
> if that will provide me with what I need.
>
>
> Best,
> Michael




More information about the FreeTDS mailing list