gregorovius has asked for the wisdom of the Perl Monks concerning the following question:

Dear Monks,

I'm looking for a database independent module for doing database management functions. At a minimum such module would support creation, deletion, backing up and restoring of databases, and would support plugin drivers for different databases, just like DBI does.

I've found DBIx::DataSource, which is almost what I need, but doesn't support backup and restoring.

Thanks in advance for any help,

Gregorovius

  • Comment on DBI like layer for database management?

Replies are listed 'Best First'.
Re: DBI like layer for database management?
by dws (Chancellor) on Apr 14, 2002 at 17:13 UTC
    I'm looking for a database independent module for doing database management functions. At a minimum such module would support ..., just like DBI does.

    How about... DBI?

    If DBI isn't satisfactory, tell us why not. That might help us make suggestions.

    If you're looking for something that assists with backup and restore, you're going outside of the normal SQL-centric client interface that RDMBSs provide. Backup/restore are typically performed using separate administrative interfaces. It's doubtful that you'll find something portable that doesn't cost $$$.

      If DBI isn't satisfactory, tell us why not. That might help us make suggestions.

      What I need this for is a testing framework for web apps that requires a fresh copy of a "known state" database to be restored before each test in a test suite runs. Tests in this suite are machine generated by way of a "snooping" proxy that records every request going to the server from a live user exercising the application. Tests work as dumb automata that simply replay the recorded sequences.

      For these sequences to run as expected, the database must be reset to the the same state in which they were recorded.

      Currently I only support MySQL and I do backup and restoring by directly invoking the mysql command line tool from my script.

      I would prefer to do backup and restoring in a less ad-hoc way, and I would also like to support other RDBMS as well. I don't think one can do this through DBI but it would be a nice if it was possible.

        What I need this for is a testing framework for web apps that requires a fresh copy of a "known state" database to be restored before each test in a test suite runs. ... Currently I only support MySQL and I do backup and restoring by directly invoking the mysql command line tool from my script.

        One way of doing this is to keep reference copies of your test data in one set of tables (say, in a parallel "reference" database), then refresh target tables by doing

        DELETE FROM foo; INSERT INTO foo SELECT * FROM reference.foo;
        This should be easily scriptable through DBI. See here for documentation on MySQL's INSERT ... SELECT

Re: DBI like layer for database management?
by trs80 (Priest) on Apr 14, 2002 at 21:53 UTC
    DBIx::Copy allows for duplicating a database, with a little cleverness you can create backup and restore utilities using it.

    The main advantage I see of using DBIx::Copy vs. a file based backup, is access rights might not allow you to write utilities to read the "raw" database files or you might not have shell access.

    What SQL engine you use may also determine what method(s) are available/best. Newer versions of MySQL include replication utilites/support.