Overview: I'm trying to create the situation in the subject line: from the outside, the database handle thinks it's just one database, but inside it's really two databases containing tables with the same schema but not necessarily the same data.
Specifics: Where I work we have a web site with content determined jointly by user interaction and by data in various tables in a very large database. I would like to test what would happen if I add other data to the database. Typically what I have to do is copy the relevant parts of the very large database to my box, add in the new data, and test locally. (The very large database is far too large to copy between machines.) There are a number of things that make this setup difficult: 1) Determining what is "relevant" is not always an easy task and is often fraught with errors. 2) The very large database can be modified by many, many other people at will. So, each time I perform a test, I have to go back to the very large database and copy the relevant parts to my box. 3) Handles to the database are created through an intermediary module. So, the call XXX::DBH->new('YYY') (where XXX::DBH is a subclass of DBI::db) returns a $dbh to the correct database (names have been changed to protect the innocent). This module relies on a configuration file to turn 'YYY' into the correct parameters for DBI->connect(); that means I'm always fiddling with the configuration file, depending if I want to use the original very large database or my local one. 4) I'd like to fiddle with the original code as little as possible, including the intermediary module. My thoughts have turned to something like DBD::Proxy, because then I could just change the environment variable DBI_PROXY when needed to switch between servers. But DBI::ProxyServer doesn't seem very easily adaptable to this situation; it seems restricted to the rather specific task of acting as a proxy for another driver. I have also thought about writing a driver from scratch, using SQL::Statement to help out, but that breaks the first rule of driver writing ("Don't!"), and since this is for my job, the second rule ("Don't -- get someone else to do it for you!") isn't really an option. I'm not afraid of putting in the time to do this right, and I'm not trying to get something for free. But I'd like some opinions about what might be the correct approaches to this problem, especially if there's something obvious that I've overlooked. (So OK, I'm trying to get some advice for free :) Thanks.