[sllug-members]: Microsoft SQL Server
Corey Edwards
tensai at zmonkey.org
Wed Apr 2 08:14:13 MST 2008
On Wed, 2008-04-02 at 02:15 -0600, Jackman wrote:
> I rather like the idea of using Perl or unixODBC to handle my SQL
> access needs, but I am a little confused on one point. Both the Perl
> DBI Interace and the unixODBC suite reference a DB Driver that is
> needed before they can do anything. I am still not sure how to go
> about it with the Perl interface, but ODBC tells me that the MS driver
> is commercial and that i have to go through a company to go about
> getting it. From a few places I get the driver resides on the server
> that I wish to use. Is the driver something that i need to worry
> about? I am mostly focussing on Perl at this point with DBI if it
> changes the way that I get help. Thanks again.
The driver you need is DBD::Sybase. It's available in CPAN. The driver
for unixODBC is FreeTDS. Mine came in a package named libsybdb5 (that's
on Debian). For Java, you need the JTDS library.
Those packages provide the low level database driver. The higher level
libraries (DBI, JDBC, etc) load the drivers and connect to the database.
To connect using Perl, here's what you would do (based off my config, so
YMMV).
1. Install FreeTDS
2. Edit /etc/freetds/freetds.conf. Add a section for your database
[myserver]
host = myserver.example.com
port = 1433
tds version = 7.0
3. Connect using DBI.
use DBI;
my $dbh =
DBI->connect('dbi:Sybase:server=myserver;database=mydb',$user,$pw);
I don't use any GUI tools, so I can't comment on that. I use Perl DBI
for scripts and I use Henplus for interactive queries. It's a Java CLI
query tool and works great.
Corey
More information about the sllug-members
mailing list