DBI->connect doesn't fail if no DB

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

DBI->connect doesn't fail if no DB

Bill McCormick-4
In the following statement ...

     my $dbh = DBI->connect("dbi:SQLite:dbname=$dbfile","","") or croak
$DBI::errstr;

if $dbfile does not exist, it is created. I would like to croak if this
happens.

Is there some option for this?

Thanks!!


_______________________________________________
sqlite-users mailing list
[hidden email]
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
Reply | Threaded
Open this post in threaded view
|

Re: DBI->connect doesn't fail if no DB

Puneet Kishor-2

On Feb 2, 2012, at 2:18 PM, Bill McCormick wrote:

> In the following statement ...
>
>    my $dbh = DBI->connect("dbi:SQLite:dbname=$dbfile","","") or croak $DBI::errstr;
>
> if $dbfile does not exist, it is created. I would like to croak if this happens.
>
> Is there some option for this?
>

I don't think so. You could simply check for the existence of the file before you connect

croak "I am dying" unless -e $dbfile;
my $dbh etc. etc.

_______________________________________________
sqlite-users mailing list
[hidden email]
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users