Собственно используем FreeTDS, /etc/freetds/freetds.conf:
Устанавливаем tdsodbc, unixodbc и libdbd-odbc-perl:[orion] host = 10.254.103.38 port = 1433 client charset = UTF-8 tds version = 8.0 text size = 20971520
Настраиваем UnixODBC, /etc/odbcinst.ini:$ sudo aptitude install tdsodbc libdbd-odbc-perl unixodbc
Ну вот, теперь пишем запрос в Perl'е:[FreeTDS] Description = FreeTDS Driver = /usr/lib/odbc/libtdsodbc.so Setup = /usr/lib/odbc/libtdsS.so UsageCount = 1
#!/usr/bin/perl -w use strict; use DBI; my $dbh = DBI->connect('dbi:ODBC:server=orion;port=1433;driver=FreeTDS;tds_version=8.0', 'username', 'password', {PrintError => 0}); die "Unable for connect to server $DBI::errstr" unless $dbh; my $rc; my $sth; #$sth = $dbh->prepare('select @@servername'); $sth = $dbh->prepare('SELECT [Caption] AS conn_details, 0 AS cnt_conn_details FROM [OrionDB].[dbo].[Nodes] GROUP BY [Caption] ORDER BY conn_details'); if($sth->execute) { while(my $dat = $sth->fetchrow_hashref) { foreach my $k (sort keys %{ $dat }) { print $k,"=>",${ $dat }{$k},"\n"; } } }
Немає коментарів:
Дописати коментар