My problem is thus:

I am currnetly access a DB with DBI. Iwould like to migrate to Class::DBI. However one of my SELECT queries must query another database.

The problem is I do not have direct access to the DB. Some sample code should explain the problem:

use DBI; my $dbh = DBI->connect('dbi:mysql:database=db1' , 'user', 'password'); my $db1_data = $dbh->selectall_hashref(qq/select * from table where field = 'value'/); my $db2_data = $dbh->selectall_hashref(qq/select * from db2.table where field = 'value');

How do I achieve this with Class::DBI? My reading of the Class::DBI docs does not show if this is possible.

I agree that the correct solution would be to connect to db2 as I did to db1. However this isn't possible for "security reasons". Personally I disagree with this but it is not an argument that I will win. :(

!unlike

I write my Perl code like how I like my sex: fast and dirty. ;)


In reply to Accessing multiple Databases with Class::DBI by !unlike

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.