For Programmers: Free Programming Magazines  


Home > Archive > PERL Modules > March 2004 > Perl module to access SQLServer from Windows platform (for newbie)









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Perl module to access SQLServer from Windows platform (for newbie)
Kona

2004-03-19, 12:55 pm

Hello,
Sorry, perhaps this question was already posted but it is not easy to
make the best choice between all reponses.
I installed ActivePerl and I would like to access to a remote
SQLServer database.
Which is the best module to do ?
Or is it papers that explains the difference between all possibilities
(odbc, ado, mssql module, dbi ...)
It is not simple for newbie !!!

Thank a lot for your advices
kz

2004-03-19, 12:55 pm

"Kona" <kona_iron@yahoo.fr> wrote in message
news:a1de658a.0403150905.55af3518@posting.google.com...
> Hello,
> Sorry, perhaps this question was already posted but it is not easy to
> make the best choice between all reponses.
> I installed ActivePerl and I would like to access to a remote
> SQLServer database.
> Which is the best module to do ?
> Or is it papers that explains the difference between all possibilities
> (odbc, ado, mssql module, dbi ...)
> It is not simple for newbie !!!
>
> Thank a lot for your advices


You have to install DBI first. If you have installed the ActiveState
distribution, DBI is installed by default (I guess).
Open a DOS prompt and enter the following:

ppm query --upgrade DBI

It will check if you have the latest version of DBI and upgrade it if
necessary.
The second thing you will need is DBD::ODBC which is a universal ODBC
driver. Again, from a DOS prompt, enter

ppm query --upgrade DBD::ODBC

to verify if your package is up-to-date.
Furthermore set up an ODBC data source pointing to your server/database via
Control Panel/Data Sources.
A typical implementation should look like this:

#!/usr/bin/perl
use strict;
use warnings;
use DBI;
use DBD::ODBC;
my $dsnname = "dsn";
my $user = "username";
my $password = "password";
my $dbh = DBI->connect("dbi:ODBC:$dsnname",$user,$password,{'RaiseError' =>
1});
#
# do whatever needed.
#
$dbh->disconnect;

Read perldoc DBI and perldoc DBD::ODBC for a detailed description of all
available methods.

HTH,

Zoltan Kandi, M. Sc.



Kona

2004-03-19, 12:56 pm

"kz" <kz15@earthling.net> wrote in message news:<mbD5c.9$Wj.7522@news.uswest.net>...
> "Kona" <kona_iron@yahoo.fr> wrote in message
> news:a1de658a.0403150905.55af3518@posting.google.com...
>
> You have to install DBI first. If you have installed the ActiveState
> distribution, DBI is installed by default (I guess).
> Open a DOS prompt and enter the following:
>
> ppm query --upgrade DBI
>
> It will check if you have the latest version of DBI and upgrade it if
> necessary.
> The second thing you will need is DBD::ODBC which is a universal ODBC
> driver. Again, from a DOS prompt, enter
>
> ppm query --upgrade DBD::ODBC
>
> to verify if your package is up-to-date.
> Furthermore set up an ODBC data source pointing to your server/database via
> Control Panel/Data Sources.
> A typical implementation should look like this:
>
> #!/usr/bin/perl
> use strict;
> use warnings;
> use DBI;
> use DBD::ODBC;
> my $dsnname = "dsn";
> my $user = "username";
> my $password = "password";
> my $dbh = DBI->connect("dbi:ODBC:$dsnname",$user,$password,{'RaiseError' =>
> 1});
> #
> # do whatever needed.
> #
> $dbh->disconnect;
>
> Read perldoc DBI and perldoc DBD::ODBC for a detailed description of all
> available methods.
>
> HTH,
>
> Zoltan Kandi, M. Sc.


Thank's a lot

But from security point of view is it the best way to access an
SQLServer throught ODBC driver ? I'm note sure.
So do you have any other experience to access this DB ?
Do you known informations where we can compare the different access
methods ?

Regards
Michael Hill

2004-03-26, 11:12 pm

>
> Thank's a lot
>
> But from security point of view is it the best way to access an
> SQLServer throught ODBC driver ? I'm note sure.
> So do you have any other experience to access this DB ?
> Do you known informations where we can compare the different access
> methods ?
>
> Regards


You can use SyBase to access sqlserver from perl like:

my $dbh = DBI->connect( "dbi:Sybase:sitesql", "username", "password", {
RaiseError => 1, PrintError => 1 } );

Mike
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com