[Zope] Using persistent DBI handle in PerlExternalMethod

Matthew T. Kromer matt@zope.com
Mon, 15 Apr 2002 10:39:35 -0400


I would guess (without knowing) that the dbi_database_connection object=20
is to the Zope Object Database; not an RDBMS interface.

What you would need to do is access the actual database connection=20
object inside the ZODB and invoke it to get a Python connection object,=20
then do whatever magic you need to to invoke its execute() method from=20
Perl, followed by invoking its fetch{one|many|all}method.

I dont know how to do that myself.


Robin Smidsr=F8d wrote:

> If I create a normal Z DBI database connection, is there a way to use t=
his
> handle to directly get the corresponding DBI $dbh for that connection?
>
> I would like to use the persistence of Zope to get rid
> of connection-penalty, but I need to use the DBI API to be able to
> make advanced scripts which calls multiple SQL-statements without the n=
eed
> to make Z SQL Methods for each one...
>
> I've looked over Zope.pm (zoperl), and taken a small look at the
> relevant ZDBI_DA files, but the solution isn't obvious.
>
> Can I use it something like this?
>
> ----------------- cut here ----------------------
> package ZopeExt::return_something;
>
> use Zope;
>
> # dbi_database_connection is defined in the Zope object tree
> # DBH is the field described in the Zope.pm BEGIN sub.
> # Is this correct?
> my $dbh=3D$Zope::DBH{'dbi_database_connection'};
>
> my $sth=3D$dbh->prepare('select * from table');
> $sth->execute;
>
> my @row=3D$sth->fetchrow;
>
> return @row;
>
> 1;
>
> ---------------- cut here -----------------------
>
>
>
> BTW: I sent this to the zope-perl mailinglist, but it doesn't look=20
> like there is much activity on that list.=20



--=20
Matt Kromer
Zope Corporation  http://www.zope.com/=20