On Tue, May 22, 2001 at 09:52:02AM -0500, STAFF wrote:
> I am writing a data replication Utility, that currently pulls a list of
> connection strings from a PG database
>
> The literal value of $sconnect_str is:
> "dbi:Proxy:hostname=eddie;port=3334;dsn=dbi:ODBC:PLAY;",'username','password',
> I'm getting the following Error:
>
> Can't
> connect("dbi::Proxy:hostname=eddie;port=3334;dsn=dbi:ODBC:PLAY;",'username','pa
> ssword', HASH(0x8144e80)), no database driver specified and DBI_DSN env var not
> set at /root/bin/sync_v1.pl line 57.
You have actually set your connect string to the value:
"dbi::Proxy:hostname=eddie;port=3334;dsn=dbi:ODBC:PLAY;",'username','password'
including quotes and commas. The connect string should actually be:
dbi::Proxy:hostname=eddie;port=3334;dsn=dbi:ODBC:PLAY
and the username and password should be separate arguments.
For example:
$connect_str = 'dbi::Proxy:hostname=eddie;port=3334;dsn=dbi:ODBC:PLAY';
$username = 'username';
$password = 'password';
konnect($connect_str, $username, $password);
sub konnect {
my($connect_str, $username, $password) = @_;
my $dbh = DBI->connect($connect_str, $username, $password,
{ RaiseError => 1, AutoCommit => 0 }
)
|| die "Database Connection failed: $DBI::errstr";
# ...
}
> sub konnect(){
> my $connect_str=shift;
That's an empty prototype on a sub that actually takes an argument. Don't
do that. Until you need prototypes, you should leave off the parens after
a subroutine declaration.
Ronald