Hardy Merrill wrote:
I took that page (actually the whole site) down a while ago. The document was very dated.------------------------------------- What is DBD::ODBC? Why can't I connect? Do I need an ODBC driver? What is the ODBC driver manager?
Where do I get an ODBC driver manager for Unix/Linux?
How do I access a MS SQL Server database from Linux?
For Unix -> Windows DB see Tom Lowery's write-up.
http://tlowery.hypermart.net/perl_dbi_dbd_faq.html#HowDoIAccessMSWin dowsDB
However, I just completed the exercise evaluating solutions for connecting to a MS SQL Server database from Linux.
When I've extra time and find the DBI FAQ again, I'll write you the methods below.
I tested 4 methods, 3 based using unixODBC with FreeTDS ODBC driver, Easysoft Bridge, and DataDirect ODBC.
The 4th was using DBD::Sybase. I had all 4 working within a 5 hours.
The FreeTDS ODBC driver is buggy (haven't had time to write up test cases to submit). Perl seg faults when attempting to insert a string into integer column, the messages aren't very descriptive (but that could be Sql Server) however it does work.
DBD::Sybase compiled against FreeTDS worked, however the driver doesn't support place holders ... major down fall.
The Easysoft bridge was the simplest to install. IIRC, Easysoft contributes to the development of unixODBC (help those who help us). The cost of packages required is very reasonable. The downside was having to install software on both Unix/Linux and MS side and speed.
The DataDirect was a tricker to install. The install script required csh, which I had to install, then the script failed. I ended up finding the tar ball and doing the install manually. Needed to edit some of the configuration files afterwards and (since I install datadirect drivers in a separate directory) add LD_LIBRARY_PATH.
The driver is fast and solid, however very very pricey.
With any of the drivers you need to add entries to odbcinst.ini and odbc.ini (either global or ~/.odbc.ini)
Here are the steps to to install unixODBC with FreeTDS: Installing unixODBC with FreeTDS Fri Jul 23 13:12:48 EDT 2004
Download source code from
unixODBC: http://www.unixodbc.org/download.html
FreeTDS: ftp://ftp.ibiblio.org/pub/Linux/ALPHA/freetds/stable/freetds-stable.tgz
Installing unixODBC tar zxvf unixODBC-2.2.9.tar.gz creates directory unixODBC-2.2.9 cd unixODBC-2.2.9
For my local install, I used the following. configure --prefix=/usr/local/odbc --disable-gui
make make check make install
Create /etc/profile.d/odbc.sh to set the environmental variables.
if [ -s "$LD_LIBRARY_PATH" ]; then
LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/odbc/lib
else
LD_LIBRARY_PATH=/usr/local/odbc/lib
fiODBCHOME=/usr/local/odbc ODBCINI=/usr/local/odbc/etc
export LB_LIBRARY_PATH ODBCHOME ODBCINI
I created a template for PostgreSQL.
create pg_template1.txt [PostgreSQL] Description = PostgreSQL driver for Linux & Win32 Driver = /usr/local/odbc/lib/libodbcpsql.so Setup = /usr/local/odbc/lib/libodbcpsqlS.so FileUsage = 1
[PostgreSQLThreads] Description = PostgreSQL driver for Linux & Win32 Driver = /usr/local/lib/libodbcpsql.so Setup = /usr/local/lib/libodbcpsqlS.so Threading = 2
Install the template into odbcinst.ini using the following sudo /usr/local/odbc/bin/odbcinst -i -d -f pg_template1.txt
I created a template for PostgreSQL for odbc.ini
[PostgreSQL] Description = Test to Postgres Driver = PostgreSQL Trace = Yes TraceFile = sql.log Database = database_name Servername = machine UserName = Password = Port = 5432 Protocol = 6.4 ReadOnly = No RowVersioning = No ShowSystemTables = No ShowOidColumn = No FakeOidIndex = No ConnSettings =
sudo /usr/local/odbc/bin/odbcinst -i -s -f pg_template_ini1.txt
Unpack the FreeTDS package. tar zxvf freetds-stable.tgz configure --help > myconfig.sh
Creating the file myconfig.sh configure --prefix=/usr/local/odbc --with-unixodbc=/usr/local/odbc make make check sudo make install Create a template file for FreeTDS driver in odbcinst.ini
[FreeTDS] Description = FreeTDS for Linux Driver = /usr/local/odbc/lib/libtdsodbc.so Setup = /usr/local/odbc/lib/libtdsS.so
Create a template file for FreeTDS for odbc.ini
[mssql_base] Driver = FreeTDS Description = Microsoft SQL Server Trace = No Server = machine TDS_Version = 8.0 Port = 1433 Database = database_name
An entry for any SQL Server Database will need added to odbc.ini
Next install DBD::ODBC With the ODBCINI, ODBCHOME, and LD_LIBRARY_PATH set (see above) Install DBD::ODBC using either CPAN or download the module CPAN: perl -MCPAN -e 'force install DBD::ODBC' Reason for the force, is the tests will fail because DBI_DSN, DBI_USER, and DBI_PASS are not set. Running the FreeTDS driver against SQL Server 2000 without SP3 installed will cause the database to crash. Or download the tar ball, doing the tar xvf tarball.tgz perl Makefile.PL make make install
To be test use the following. dbish "dbi:ODBC:mssql_base" user password if all works right you should see [EMAIL PROTECTED]:ODBC:mssql_base>
