http://www.perlmonks.org?node_id=43760


in reply to Topics in Perl Programming: Table-Mutation Tolerant Database Fetches with DBI

If you expect to have to access a database with colums that change then it's time for you to embrace a buzzword or two.

Essentially you need to tuck away all the bits of your code which actually talk to the database. Make a module with an OO interface, ensure that remains constant in time, then any changes in the database structure (or even the method of actually storing the data) become moot.

Then to get at some data all you'd need to do is:

@values = $abstracted_db->beans_with_colour('red');

Now, doing that might take a bit of thought, but in the end it will pay off. The main drawback is that it slows you down a bit, but when you talk to databases, you're going to be fairly slow anyway.

  • Comment on Re: Topics in Perl Programming: Table-Mutation Tolerant Database Fetches with DBI
  • Download Code