Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re^2: RFC: Array::GroupBy (DBD::Sponge)

by kyle (Abbot)
on Jan 06, 2009 at 21:19 UTC ( [id://734501]=note: print w/replies, xml ) Need Help??


in reply to Re: RFC: Array::GroupBy
in thread RFC: Array::GroupBy

Can you show an example of how you'd use those modules to do what mine does? From the documentation I'm looking at, it appears DBD::Sponge is used for making some data appear to be from some SQL, not for doing any kind of transformation.

use DBI; my $sponge = DBI->connect( 'dbi:Sponge:', '', '', { RaiseError => 1 } +); my $sth = $sponge->prepare( 'SELECT name,count(*) FROM ??? GROUP BY na +me', { NAME => [ 'name', 'count' ], rows => [ [ 'fred ', 10 ], [ 'john ', 20 ], [ 'jdporter', 30 ], [ 'jdporter', 40 ], ] } ); while ( my @row = $sth->fetchrow_array ) { print join ', ', @row; print "\n"; } __END__ fred , 10 john , 20 jdporter, 30 jdporter, 40

Replies are listed 'Best First'.
Re^3: RFC: Array::GroupBy (DBD::Sponge)
by jdporter (Paladin) on Jan 06, 2009 at 22:07 UTC

    You're right, my bad. Despite allegedly supporting SQL::Statement::Syntax, in fact DBD::Sponge essentially ignores the statement and does a plain ol' SELECT *.... and the only use I can envision for that is as a bridge between your perl data and some black-box module which requires a statement handle.

    The documentation of DBD::Sponge's prepare() is pretty unclear on this issue:

    The $statement here is an arbitrary statement or name you want to provide as identity of your data. If you're using DBI::Profile it will appear in the profile data.

    Generally it's expected that you are preparing a statement handle as if a select statement happened.
    huh?

    Anyway, sorry for the red herring.

    Update: I checked into a couple of DBD modules which allow to access in-memory perl data structures as sources for DBIDBD::AnyData and DBD::RAM (both, like SQL::Statement and other parts of the DBIverse, by jZed). Alas, neither supports GROUP BY!

    Between the mind which plans and the hands which build, there must be a mediator... and this mediator must be the heart.

      It wouldn't have been a perfect solution anyway; SQL::Statement's GROUP BY implementation is incomplete.

      (Looks like the module's being worked on again now, so I've reported the bug once more...)

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://734501]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others chilling in the Monastery: (3)
As of 2024-04-25 07:44 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found