in reply to Re: check if databse exists before connection is made!
in thread check if databse exists before connection is made!

so what can i do about it now? this scripts fails to execute if the database doesnt exist!! so its not working properly! what can i do to fix it?
  • Comment on Re: Re: check if databse exists before connection is made!

Replies are listed 'Best First'.
Re: Re: Re: check if databse exists before connection is made!
by derby (Abbot) on Feb 06, 2004 at 16:01 UTC
    Uhh .. errr ... uhhh ... check for return values and do what you need to? Basically, you're doing a bunch of stuff without checking return values. Also, you have RaiseError set on one of your connects so you could wrap the code inside an eval.

    my $dbh = DBI->connect( $dsn, $user, $password, { RaiseError => 1 } ); if( ! $dbh ) { print "Ugg, connection problem: $DBI::errstr\n"; } else { eval { $dbh->do( whatever ); $dbh->do( something else ); }; if( $@ ) { print "Ugg, problem: $@\n"; } }
    -derby
Re: check if databse exists before connection is made!
by Abigail-II (Bishop) on Feb 06, 2004 at 16:03 UTC
    Either of two things: check the return value of the connect method, and if it fails, check the reason. Or connect to a database you know exists, and once connected, check to see whether the database you are interested in exists.

    Abigail