Dear List,

The short version of my question is: Using DBD::DBM, is there a simple way to tell whether a table exists? (Other than just trying to query it and handling failure.)

I've tried "$dbh->{'dbm_tables'}" which seemed promising, except that it's always empty until I actually execute a query.

I've tried "$dbh->func('list_tables')" but that just lists all the files in the directory. I'd rather not use that because I'd rather not have to remember how the particular DBM handles extensions.


The longer version of the question, with the rest of the story, is below.

Thanks for any advice,

dave

--

I have a little application that tracks state of tickets. I wrote a proof-of-concept using DBI and DBD::SQLite. A colleague suggested I try a different backing store, like BerkeleyDB or GDBM. "No problem," said I, "I'll just switch to DBD::DBM."

Of course, I had cheated.  In the SQLite version, I had the statement

        CREATE TABLE IF NOT EXISTS tickets (...)

at the very beginning. For the DBM version, I have to remove the "IF NOT EXISTS" phrase. The code "works", but its output is peppered with warnings like


DBD::DBM::st execute failed: Cannot CREATE './tickets.pag' because it already exists at /usr/lib64/perl5/site_perl/5.8.8/x86_64-linux-thread-multi/DBD/DBM.pm line 338.

Those are just warnings and everything else seems to work. At least with SDBM.

Reply via email to