in reply to Checking for DB table existence using DBI/DBD

Oddly enough, I had a requirement to do the same yesterday, and found that this works:

use DBI; use strict; my $db=DBI->connect("DBI:SQLite:dbname=testdb","",""); my $sth = $db->prepare("select * from nosuchtable"); if ($sth){print "Table exists\n"} else{print "No such table\n"}

(i.e. without doing an execute).

The code displays a warning from SQLite that the table doesn't exist, and the true test for $sth fails. Of course, this might be a bad way (if it is, I'd like to know so I can change it in my code).

--------------------------------------------------------------

$perlquestion=~s/Can I/How do I/g;