Darren Duncan wrote:
For a loose DBI-alike example:

    use FooDB;
    my $dbms = FooDB->select();  # the DBMS is a singleton
my $sth = $dbms->prepare(<query code here>); # also "connect" with query code
    $sth->execute(<query params go here>);
    ...

From an initial response, I see that this code example may be confusing, and so I'll provide one that's a bit more accurate, but still a bit pseudo-codey:

    use FooDB;
    my $machine = FooDB::select_machine();  # the VM is a singleton

    my $process = $machine->new_process();  # a "connection" to the VM

    $process->proc_invo( 'create_depot_mount', {  # like DBI->connect()
        name          => 'db'   ,  # namespace to mount this db schema under
        we_may_update => 1      ,  # db access not read-only
        details       => [ ... ],  # server/user/pass etc for this db schema
    } );

    $process->proc_invo( 'create_procedure', {  # like DBI prepare() or DDL
        depot    => 'app'  ,  # namespace to install query in
        name     => 'get_x',  # name of the query
        material => ...    ,  # query code here, defined like an sproc
    } );

    my $gotten_x;
    $process->proc_invo( 'fed.lib.app.get_x', {  # like DBI execute()
        gotten_x  => \$gotten_x,  # subject-to-update/INOUT param
        name_of_x => 'joe'     ,  # read-only/IN param
    } );

    my $x = $gotten_x->as_perl();

So hopefully it is more clear now how the module is supposed to work.

Note the uniformity of interface. Anything that you could conceivably have done as a SQL statement in some DBMS you can do via proc_invo, which includes "CONNECT" SQL.

The purpose of mount-points here, among other things, is to effectively support cross-database queries. A direct analogy in SQLite is called ATTACH DATABASE.

About the only bit of this code that is somewhat implementation-specific is what goes into "details", in the same way that connection strings in DBI vary per driver.

I could also define "routine handles" but haven't yet; if I did it could be like this:

    my $get_x = $process->proc_handle( 'fed.lib.app.get_x' );
    my $gotten_x;
    $get_x( {  # like DBI execute()
        gotten_x  => \$gotten_x,  # subject-to-update/INOUT param
        name_of_x => 'joe'     ,  # read-only/IN param
    } );

Or I could add support for anonymous procedures to the Perl module, which are even more like DBI's statement handles; they still have names, but the computer generates the name, and practically speaking you'd only call it by the handle.

-- Darren Duncan
_______________________________________________
muldis-db-users mailing list
muldis-db-users@mm.darrenduncan.net
http://mm.darrenduncan.net/mailman/listinfo/muldis-db-users

Reply via email to