Re: DBD::XML
Nigel Horne <[email protected]>
| Newsgroups | gmane.comp.lang.perl.modules.dbi.general |
|---|---|
| Message-ID | <[email protected]> |
On 19/8/16 11:51, Tim Bunce wrote: > 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? Nope, that's me creating random test data to poke around. > >> use DBD::XML; > (Ideally users shouldn't need to use the driver module explicitly.) I'm assuming after registration that would go away, or am I wrong? > >> 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'? "Pinched from" to get a bootstrap while I'm developing before registration. > >> 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.) Thanks for the pointer - that's useful to know. > > Are any other XML Schema supported, or supportable? I hope so, once I'm ready to create more test data beyond the trivial stuff I'm using to get started. > > 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? I'm hoping to do chunk by chunk, but that's not done yet. > In other words, can it read files larger than the available memory? > (Not related to the naming, just curious :) I really hope so, but not yet. I need to walk before I can run :-) -Nigel > > Tim.