in reply to Problems with DBD::ODBC and DBD::Sybase

I don't use DBD::Sybase so cannot comment on #1 but I do know about DBD::ODBC and a little about FreeTDS. For a background on ODBC in unix see http://www.easysoft.com/developer/interfaces/odbc/linux.html - I know it says Linux/UNIX but most of it applies to OSX too.

OSX comes with a modified iODBC driver manager and from the looks of things you are already using that - or DBD::ODBC would not have built. You need to add your FreeTDS ODBC driver with the ODBCAdmin GUI program then create a datasource. I don't own a MAC so I'm not sure if FreeTDS includes the libraries to add a driver with ODBCAdmin but if it does not then you can hand edit the odbcinst.ini file. Use iodbc-config --odbcinstini to find where the odbcinst.ini file is and and add a driver something like this:

[ODBC Drivers] FreeTDS = Installed [FreeTDS] Driver = /path/to/libtdsodbc.so

Then fire up ODBCAdmin and create your data source. You'll need to add attributes to say where your sql server is, what protocol to use, username, password etc - best to consult the FreeTDS home page for that. Here again, you can just run iodbc-config --odbcini and it will tell you which files to use to define your user and system data sources in. I've included a very simply data source definition I used some time ago with FreeTDS and MS SQL Server below.

[freetds] Driver = FreeTDS Description = connection to RS machine Trace = No Server = 192.168.250.71 #Database = pubs TDS_Version = 7.0

ODBC is pretty much the same across unix-like platforms but typically OSX has it differences e.g., you get the iODBC driver manager by default whereas most of the rest of the unix world use the unixODBC driver manager. Also, it may be possible FreeTDS cannot get its settings from the odbc.ini file directly - it needs special parts of the ODBC driver manager (SQLPrivateProfileString etc to do that). If that is the case, you can put the settings in your freetds.conf file but the freetds page is the best place to start researching that. I don't own or have a MAC to hand right now but I got DBD::ODBC working on OSX in the past.

Replies are listed 'Best First'.
Re^2: Problems with DBD::ODBC and DBD::Sybase
by rwitmer (Initiate) on May 28, 2009 at 20:46 UTC
    Okay, I read the background info you posted. Thanks, that made it a lot clearer. Then I ran the command you suggested to find odbcinst.ini. It worked, see:

    rebecca-witmers-macbook-pro-15:jtds-1.2.2-dist rwitmer$ iodbc-config --odbcinstini
    /Library/ODBC/odbcinst.ini

    The trouble is, when I go there, nothing is there. Really:

    But that's in the directory for OSX 10.4. My machine has 10.5. What's the deal here? Do I have this driver manager thing or what? I am confused.

      I see you have also posted to the FreeTDS list - that is a good idea. The fact that you can run iodbc-config shows you do have the iODBC driver manager installed. The --odbcinstini argument is telling you which file to add your drivers to. If the file does not exist, create it. Similarly with the odbc.ini file.

      iodbctest is the command line app you can use to test your dsns are working. iodbctestw is a unicode aware version of the same app.

      You need to go ahead and create your odbcinst.ini and odbc.ini files based on my previous comments and the help on the freetds web site detailing what to put in them. But bare in mind the freetds site instructions are probably for the unixODBC driver manager and iODBC (the driver manager you are using) is slightly different in the way you name driver and data sources - see my previous reply.

      I'm no expert OSX person but if you get no joy from the freetds list I might be able to help further.

        Okay, here's the answer:

        Like the previous commenter said, to get Sybase to install you have to read the suggestion here:

        http://www.mail-archive.com/dbi-users@perl.org/msg31071.html

        Those symbols are missing from the FreeTDS include files.

        Edit dbdimp.c, and somewhere near the top add:

        #define BLK_VERSION_150 BLK_VERSION_100 #define BLK_VERSION_125 BLK_VERSION_100 #define BLK_VERSION_120 BLK_VERSION_100

        Then recompile.

        Also, do not try testing using the scripts here: http://www.freetds.org/userguide/perl.htm#DBD.SYBASE

        Because there is no Sybase public server since about 10 years ago, apparently. Definitely not now.

        Also, you have to remember that if something freezes up and you get irritated and shut down your machine, when you turn it back on you have to reset your SYBASE environment variable or it will not find the driver that freetds comes with. Doh.

        Thanks for all your help! I definitely understand the way it works much better now that I looked at it really closely at the least.