in reply to Determining if SQLite db exists

Hi Tony

If you're looking for a solution where the connect() returns a "Database file does not exist" instead of checking for the existance of the file yourself, then your best bet is to contact Mat Sergeant who wrote DBD::SQLite. Ask politely for the new feature using rt.cpan.org.

This is because, as others have already mentioned, that this particular feature is DBD specific. You could always subclass DBD::SQLite and write the check yourself, but I would recommend against it unless you are familiar with Perl's ways of OOP. Do *NOT* modify DBD-SQLite directly yourself as the next time you update your cpan modules, it will be overwritten.

Order of preference:

  1. test the file existance yourself
  2. have DBD::SQLite maintainers make the modification
  3. subclass DBD::SQLite

Hope this helps

Jason L. Froebe

Team Sybase member

No one has seen what you have seen, and until that happens, we're all going to think that you're nuts. - Jack O'Neil, Stargate SG-1

Replies are listed 'Best First'.
Re^2: Determining if SQLite db exists
by jZed (Prior) on Feb 28, 2005 at 17:06 UTC
    Mostly good advice, though I'd add this caveat: Matt probably wouldn't and shouldn't change the default behaviour. There are lots of scripts out there that depend on the automatic database creation. I suppose the best way (if it belongs in the module at all) would be to allow users to pass a "sl_no_db_create" attribute in connect() that would trigger the die on non-existant database behaviour

      An excellent point, to which I would only add that producing a patch to implement such a flag would almost certainly greatly enhance its likelihood of being included in a future release. (Why yes, I'm having a jargon-heavy day at work, why do you ask?)



      If God had meant us to fly, he would *never* have given us the railroads.
          --Michael Flanders

      I totally agree :) Setting an attribute for this behavior would be best - if such a change to DBD::SQLite were to be made

      Jason L. Froebe

      Team Sybase member

      No one has seen what you have seen, and until that happens, we're all going to think that you're nuts. - Jack O'Neil, Stargate SG-1