Phoenix.pm: UNIX-Microsoft SQL server connection

Scott Walters phaedrus at illogics.org
Wed Feb 6 18:39:59 CST 2002


I'm going to chip in with my 2 cents even though I'm not
a Windows user...

First, DBI has a DBD::ODBC module that it uses. DBI is just an
interface to different DBD:: modules, so that all databases have
the same interface to the program. It should be able to connect
to any ODBC database. The docs say it handles MS-SQL without
problems. I don't know which database you are using. Will
work with Oracle, DB2 etc also, but other databases have
faster specialized more powerful interfaces.

Info on DBD::ODBC and WIn32::ODBC... 

http://www.perldoc.com/perl5.6.1/lib/DBI/FAQ.html#3.2-What's-the-difference-between-Win32--ODBC-and-DBD--ODBC-

DBD::ADO might be cool: 

http://www.perldoc.com/perl5.6.1/lib/DBD/ADO.html

$dbh = DBI->connect('DBD:ODBC', $username, $auth, \%attr);
$sth = $dbh->prepare(qq{
  insert 
  into   table
         (field, otherField, someOtherField)
  values (?, ?, ?)
});
open $f, "file" or die $!;
while(<$f>) {
  $rv = $sth->execute(split, /("?),\1/, $_);
}
close $f;

... you'll have to fill in a lot of stuff there...
what to split the columns on, login info for the database, 
whatever DBD:ODBC says you should use for the first arg of DBI->connect,
names of the columns, number of columns, name of the table...
feel free to hack it up, and if you get stuck, post it back to the
list (without the password and username in the first line),
and well take a look at it..

-scott


On Wed, 6 Feb 2002, N wrote:

> HI
> I was wondering what PERL module I could use to load a
> UNIX flat text data file into a SQL Server database
> running on a Windows Server.
> Alternatively, are there FREE unix-windows ODBC
> drivers available that you might be aware of?
> THanks
> Rgds
> Nishant
> 
> __________________________________________________
> Do You Yahoo!?
> Send FREE Valentine eCards with Yahoo! Greetings!
> http://greetings.yahoo.com
> 




More information about the Phoenix-pm mailing list