On 24/06/13 16:01, H.Merijn Brand wrote:
In the git branch "f_dir-ref" (a wrong name now, as we changed some
things in the development process), you can find a new extension

DBD::File now understands a new attribute f_dir_search:

   f_dir_search

     This optional attribute can be set to pass a list of folders to also
     find existing tables. It will not be used to create new files.

That does not make sense to me. Does it really mean:

This optional attribute can be set to a list of folders which will be searched 
for existing tables and is not used when creating new tables.

BTW, I presume you normally use the word folder (bit of a Windows thing) rather 
than directory (f_dir_search also suggests directory not folder).

       f_dir_search => [ "/data/bar/csv", "/dump/blargh/data" ],

A real-world example might explain this in more detail using DBD::CSV

my $dbh = DBI->connect ("dbi:CSV:", undef, undef, {
     f_schema         => undef,
     f_dir            => "tmp",
     f_dir_search     => [ "sandbox", "/tmp" ],
     f_ext            => ".csv/r",
     f_lock           => 2,
     f_encoding       => "utf8",

     RaiseError       => 1,
     PrintError       => 1,
     FetchHashKeyName => "NAME_lc",
     }) or die "$DBI::errstr\n";

This will set the default folder for CSV files to be located in the
folder "tmp". This folder will also be used for creating tables.

When opening a handle to an already existing table, and that table's
file(s) cannot be found in the folder indicated by "f_dir", the folders
in the "f_dir"search" (if present) will be searched for the files
needed to open the table.

   my $sth = $dbh->prepare ("select * from foo");

will, using the above example, search for

   tmp/foo.csv
   sandbox/foo.csv
   /tmp/foo.csv

The DBI test suite tests this option in t/51dbm_file.t

If people have feedback, it would be appreciated. Both possitive and
negative. If no objections exist, I'd like to merge this branch into
master and request a new release, so we can release DBD::CSV shortly
after


Martin

Reply via email to