Re: DBD::XML

Tim Bunce <[email protected]>
Newsgroups gmane.comp.lang.perl.modules.dbi.general
Message-ID <[email protected]>
On Fri, Aug 19, 2016 at 10:09:45AM -0400, Nigel Horne wrote:
> On 8/19/16 9:56 AM, Tim Bunce wrote:
> > On Fri, Aug 19, 2016 at 09:30:32AM -0400, Nigel Horne wrote:
> > > 
> > > Apart from one change I need to make in terms of column names, I'm pretty
> > > much ready to start working on a 0.01 CPAN release.  It's read-only, but
> > > that's all I need.  How do I set about requesting driver registration, or is
> > > this mentioning enough?
> > Probably :)
> > 
> > But I wonder about the name. "DBD::XML" seems to be a bold name,
> > implying that it's _the_ DBI interface for data stored in XML files.
> > Of course the same kind of issue applies to many other drivers,
> > so it's not a major concern, but does seem worth dicussing.
> 
> I'm more than happy to entertain other names if you have any suggestions.

I've some random questions and observations below...

> So, here's the example I've started with to get the code basic interface
> going and tested.  The code I have works with this trivial example.
> 
> data/person.xml:
> 
> <?xml version="1.0" encoding="US-ASCII"?>
> <table>
>     <row id="1">
>         <name>Nigel Horne</name>
>         <email>[email protected]</email>
>     </row>
>     <row id="2">
>         <name>A N Other</name>
>         <email>[email protected]</email>
>     </row>
> </table>

Does that format ('table', 'row', 'id') correspond with a known XML Schema?

> use DBD::XML;

(Ideally users shouldn't need to use the driver module explicitly.)

> my $dbh = DBI->connect('dbi:XML(RaiseError => 1):');
> $dbh->func('person', 'XML', "$Bin/../data/person.xml", 'ad_import');  # to be replaced with xml_import once the driver has been registered

I presume ad_import comes from DBD::AnyData. Is that 'inspired by',
or 'is a fork of', or 'using under the hood'?

> my $sth = $dbh->prepare("SELECT * FROM person");
> $sth->execute();
> 
> while (my $href = $sth->fetchrow_hashref()) {
>     my $d = Data::Dumper->new([$href]);
>     print "got data:\n", $d->Dump();
> }

($sth->dump_results can be handy for little example scripts.)

Are any other XML Schema supported, or supportable?

Is the XML and/or the parsed data loaded into memory or does each
$sth->fetch call pull the next chunk from the XML parser?
In other words, can it read files larger than the available memory?
(Not related to the naming, just curious :)

Tim.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.