Fellow DBIers,

So I just had a need to use DBI::Shell with a subclass of the DBI. It doesn't support subclasses directly (it'd be nice to be able to specify one on the command-line or something), but I was able to hack it into using one anyway by doing this:

  BEGIN {
      sub DBI::Shell::Base::DBI () { 'My::DBI' };
  }
  use DBI::Shell;

Yes, is extremely sneaky. DBI::Shell::Base uses the string constant "DBI", as in

  DBI->connect(...)

So by shoving a constant into DBI::Shell::Base before loading DBI::Shell, I convince it to use my subclass, instead.

Enjoy,

David

Reply via email to