Laziness: not *always* a virtue

hex on 2003-11-20T11:08:30

I just spent about three quarters of an hour trying to debug a bizarre DBI-related error that appeared this morning. I was getting this message:

DBI connect('db=/home/earle/Work/Thing/lib/Thing/thing.db','',...) failed: unable to open database: db=/home/earle/Work/Thing/lib/Thing/thing.db at /home/earle/Work/Thing/lib/Thing/DB.pm line 40

Googling for "DBI connect" "unable to open database" gets only 5 hits, and two of those are posts to the Siesta development list. It wasn't until I did a diff against an earlier version of the code that I found the problem:

-my $dbh = DBI->connect("dbi:SQLite:dbname=$dbname", "", "",
+my $dbh = DBI->connect("dbi:SQLite:db=$db", "", "",

I'd decided before the end of yesterday to remame the variable $dbname to $db, because it contains a path as well as just a database name. And so I did a global search-and-replace and promptly clobbered the DBI connect string. Oops. (Of course, it would have helped if DBI had given me a slightly more informative error message....)