Re: Fwd: Re: DBD::XML

2016-08-20 Thread Ron Savage

Hi Nigel


This usage of $ABCx or $AbcX is a wide-spread convention. E.g.
Marpa::* is exclusively used by Jeffrey Kegler, and all ours are
MarpaX::*. But there are many, many modules called ${Something}x::* as
add-ons to $Something.

And yes, for DBI and other it's 'x', elsewhere it's often 'X'.


For clarification, are you saying that my driver should be called
DBDx::XML?  The reason I ask is that all the DBDx::* modules I could
find seem to be extensions to DBI or things that use DBI, rather than
DBI drivers or backends.


Not exactly. I'm rather saying that drivers of specific types (i.e. 
behave in specific ways) do follow a standardized naming convention. 
It's then up to you to decide if your module resembles those others, or not.



Also would that confuse with the existing DBIx::XML code?  That does
something entirely different.


Indeed it would. So don't do that :-).

--
Ron Savage - savage.net.au


Re: DBD::XML

2016-08-20 Thread Nigel Horne



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:



 
 Nigel Horne
 n...@bandsman.co.uk
 
 
 A N Other
 nob...@example.com
 


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.




Fwd: Re: DBD::XML

2016-08-20 Thread Nigel Horne


Hi Ron,

On 19/8/16 20:24, Ron Savage wrote:

Hi Nigel

On 20/08/16 01: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:

[snip]

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.


As a rule, we have DBI (there's just one) and anything it uses
(DBI::*), and then we have DBIx::* for all our additions in thefield.
That is, we all agree to explicitly avoid using DBI::*. Even drivers
loaded by DBI are called DBD::Pg, DBD::mysql, DBD::SQLite, etc.

This usage of $ABCx or $AbcX is a wide-spread convention. E.g.
Marpa::* is exclusively used by Jeffrey Kegler, and all ours are
MarpaX::*. But there are many, many modules called ${Something}x::* as
add-ons to $Something.

And yes, for DBI and other it's 'x', elsewhere it's often 'X'.


For clarification, are you saying that my driver should be called
DBDx::XML?  The reason I ask is that all the DBDx::* modules I could
find seem to be extensions to DBI or things that use DBI, rather than
DBI drivers or backends.

Also would that confuse with the existing DBIx::XML code?  That does
something entirely different.

-Nigel