On Wed, Dec 15, 2004 at 12:28:49PM +0000, Jeff Zucker wrote:
> I am thinking of extending the DBD::AnyData DSN in three ways and would 
> appreciate comments.  If these are good, there will be equivalent 
> changes for DBD::DBM and DBD::CSV.
> 
> 1. Allow db and dbname as aliases for f_dir for compatability with other 
> DBDs.  A directory is, in some cases equivalent to a database (a 
> collection of tables), although in other situations (e.g. XML) a single 
> file may be a database, so the terms are not exactly equivalent, oh well.

Okay, but the recommended names are "db" and "database" (not "dbname").

> 2. Support an extended syntax for the DSN which would allow use of 
> DBD::AnyData without needing $dbh->func(), $dbh->ad_catalog(), or 
> $dbh->ad_import() methods.  These three would be the same:
> 
>  a. $dbh=DBI->connect( 'dbi:AnyData:XML:table=Test;file=test.xml' );

After the "dbi:AnyData:"; everything should be in "name=value;" format.
So "dbi:AnyData:format=XML;table=Test;file=test.xml";

>  b. my $flags = {format=>'XML',table=>'Test',file=>'test.xml'};
>     $dbh=DBI->connect('dbi:AnyData:','','',$flags);

You've called it $flags but it's really \%attr, and the rules for
attr are that driver private attributes should have a driver-specific
prefix. So, for example:

   b. my $flags = { ad_format=>'XML', ad_table=>'Test', ad_file=>'test.xml'};

>  c. $dbh=DBI->connect('dbi:AnyData:');
>     $dbh->ad_catalog('Test','XML','test.xml');


> 3. Support a tables hash attribute in the connection which would allow 
> importing or cataloging multiple tables at the same time.  The keys of 
> the hash are table names, the values are either a DSN string, or an 
> attribute hashref, or both.  For example:
> 
>  my $dbh = DBI->connect( 'dbi:AnyData:','','',{ tables=>

Should be "ad_tables" instead of "tables".

>      { A => 'CSV:file=test.csv'

         A => 'format=CSV;file=test.csv'

>      , B => 'Pipe:file=test.pipe;com=import'

       , B => 'format=Pipe;file=test.pipe;com=import'

>      , C => {data=>$aryref}
>      , D => [ 'dbi:Pg:dbname=jz1',{sql=>$sql} ]
>      }
>  });
>  # use DBI/SQL to access tables A,B,C, and D

Other than those minor points, it looks good to me.

Thanks!

Tim.

Reply via email to