On Fri, Aug 16, 2002 at 09:53:40PM -0700, Dean Arnold wrote:
> I'm trying to figure out how whether DBIx is the family I'm looking for...
> 
> Some of you may be aware of DBD::Chart.
> Its finally matured enough now (at least I hope so)
> that I'd like to extend it to make every DBMS (er, rather every DBD) look
> like it provides native charting ability, e.g.,
> 
> SELECT LINEGRAPH FROM
> (SELECT * FROM someOracleTable WHERE this=that...)
> WHERE WIDTH=400 AND HEIGHT=....

Cool.

> My initial assumption was that DBIx
> was the "home" of such a concept (ie, doing a minimal pre-parse of SQL
> to determine if a chart was requested; if not just pass things off to DBI,
> otherwise, do some more heavy lifting in w/ DBD::Chart).
> But after pawing thru various DBIx modules, their purpose seems
> to be to minimize (eliminate?) SQL use as much as possible.

The DBIx::* namespace only exists to provide a home for *any* modules
which are _very_ closely tied to the DBI but which are not part of
the DBI.

> I guess I've been slinging SQL too long, but I find SQL a very useful
> and capable language (esp when coupled w/  Perl 8^) esp. with the
> VLDBMS systems I deal with.
> Hence DBD::Chart (using SQL to build charts/graphs from data).
> 
> Q: Is DBIx where my concept belongs ?
> If not, where ?
> 
> If so, are there any DBIx modules I can
> cheat from to figure out how to subclass DBI wo/ having to replicate
> every DBI method ? (This maybe my ignorance of Perl OO programming showing)

Look at t/subclass.t in the DBI distribution.

But is subclassing the DBI actually the best way to implement this?

At first sight I'd think it would be better to teach DBD::Chart about
how to talk to other drivers. Perhaps something like

    $dbh_chart = DBI->connect("dbi:Chart:...", ...);
    $dbh_ora   = DBI->connect("dbi:Oracle:SALES", ...);
    $dbh_mysql = DBI->connect("dbi:mysql:LOG", ...);

Teach DBD::Chart about names for database handles:

    $chart_dbh->{chart_dbh_names}->{Sales} = $dbh_ora;
    $chart_dbh->{chart_dbh_names}->{Log}   = $dbh_mysql;

Than add some way to indicate which named database handle to use
for the statement.  For example:

    $chart_sth = $chart_dbh->prepare(qq{
        SELECT LINEGRAPH FROM
        (SELECT * FROM Sales.someTable WHERE this=that...)
        WHERE WIDTH=400 AND HEIGHT=....
    });

But other ways (that are simpler to parse) may be better.

Tim.

Reply via email to