SPUG: Unix to MS SQL Server Using Perl and ODBC
Charles DeRykus
ced at carios2.ca.boeing.com
Wed Feb 9 18:21:08 CST 2000
> Has anyone configured Perl on a Unix box (Solaris in my case) to query
> a remote Microsoft SQL server using ODBC? If so, what Perl modules did
> you use? What did you use for the driver and the driver manager? I haven't
> been able to put all the pieces together for what I thought was a pretty
> simple problem.
I'm also interested but haven't yet tried this item I
saw on DejaNews:
Please let me everyone know if you get this to
work and I'll do the same.
Rgds,
--
Charles DeRykus
(from: http://ftp.digital.com/pub/plan/perl/CPAN/modules/01modules.index.html)
How do I access a MS Windows based database from UNIX/Linux using
DBI::Proxy?
* On the UNIX/Linux machine install DBI and all the modules to support
DBD::Proxy.
* On the Windows system install DBI, all the modules for DBD::Proxy, and
DBD::ODBC.
* Define a system DSN (using ODBC connection manager) to the Windows
database.
* Using the ODBC Test connection, test the ODBC connection.
Now, configure the proxy server on the Windows machine. Here is a sample of
my test configuration:
dbiproxy.conf
{
'localport' => 1234,
'pidfile' => 'c:\tmp\dbiproxy.pid',
'logfile' => 1,
'debug' => 1,
'mode' => 'threads',
'timeout' => 60,
'clients' => [
{
'mask' => '^lowery-t$',
'accept' => 1
},
{
'mask' => '^localhost$',
'accept' => 1 },
{
'mask' => '.*',
'accept' => 1
}
]
}
Start dbiproxy on the Windows machine:
c:\dbiproxy --configfile=c:\tmp\proxy.conf
On the UNIX/Linux machine do the following:
* Modify this script to access the Windows NT machine:
use DBI;
use Data::Dumper;
my $dbh = DBI->connect(
'dbi:Proxy:hostname=YourMSHostName;port=1234;dsn=dbi:ODBC
:YourDSN' , 'UserId', 'PassWord', { RaiseError => 1, PrintError => 1 } ) or
die $DBI::errs
tr;
my $sth = $dbh->prepare( 'select * from authors (YourTable)' );
$sth->execute;
while( $row = $sth->fetchrow_hashref ) {
print Dumper($row);
}
$sth->finish;
$dbh->disconnect;
* At the command prompt, execute using perl -w scriptname.pl
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
POST TO: spug-list at pm.org PROBLEMS: owner-spug-list at pm.org
Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/
SUBSCRIBE/UNSUBSCRIBE: Replace ACTION below by subscribe or unsubscribe
Email to majordomo at pm.org: ACTION spug-list your_address
More information about the spug-list
mailing list