New attribute for DBD::File

"H.Merijn Brand" <[email protected]>
Newsgroups gmane.comp.lang.perl.modules.dbi.sybase.devel
Message-ID <[email protected]>
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" ],

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/
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.