On Mon, 24 Jun 2013 17:01:51 +0200, "H.Merijn Brand" <h.m.br...@xs4all.nl> 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. > > f_dir_search => [ "/data/bar/csv", "/dump/blargh/data" ], In a new branch on DBI, I have extended that idea (not enough tests and no documentation yet) with hash entries f_dir_search => [ { f_dir => "sandbox", f_schema => "testfiles", }, { f_dir => "/data/reference/iso-1234/csv", f_schema => "iso1234", f_readonly => 1, }, ], f_schema and f_dir work, but as f_readonly is not (yet) been implemented (like this), it does not. > 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 -- H.Merijn Brand http://tux.nl Perl Monger http://amsterdam.pm.org/ using perl5.00307 .. 5.19 porting perl5 on HP-UX, AIX, and openSUSE http://mirrors.develooper.com/hpux/ http://www.test-smoke.org/ http://qa.perl.org http://www.goldmark.org/jeff/stupid-disclaimers/