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.

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' );

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

 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=>
     { A => 'CSV:file=test.csv'
     , B => '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

If db or format is supplied in the DSN, it will be a default for all tables, so this would look for all the files in the /home/me directory and expect them to be in CSV format without needing to specify the directory or format for each table:

 my $dbh = DBI->connect( 'dbi:AnyData:CSV;db=/home/me','','',{ tables=>
     { A => 'file=test1.csv'
     , B => 'file=test2.csv'
     }
 });

Thanks for your comments.

--
Jeff



Reply via email to