Am 10.09.2013 um 21:45 schrieb Curtis Leach <[email protected]>:
> Hello,
Aloah /o\
>
> I’m having issues trying to query flat files using DBI & DBD::CSV. I’m
> currently upgrading from v5.8.8 to v5.16.3 and with the latest Perl platform
> my code no longer works. I’m running on various Windows platforms.
>
> I’m going to Strawberry Perl v5.16.3 (32-bit)
> DBI 1.628 (upgraded core module)
> DBD-CSV 0.41
> SQL-Statement 1.405
> Text-CSV_XS 1.01
>
> From: Active State Perl v 5.8.8
> DBI 1.49
> DBD-CSV 0.22
> SQL-Statement 1.14
> Text-CSV_XS 0.23
>
> Here is a code sample that reproduces my issue:
>
> my %attr = (PrintError => 0, RaiseError => 1, AutoCommit => 1);
> my $dbh = DBI->connect ("DBI:CSV:csv_sep_char=|;csv_eol=\n", "", "", \%attr);
> $dbh->{csv_tables}->{logs} = { 'file' => basename ($src_file) };
Please use f_file instead of file (see Changes).
For a long time, "file" was handled as a depreciated flag and was mapped to
f_file.
It might be removed sooner or later (or maybe is, see alias def in
DBD::File::Table).
> $dbh->{f_dir} = dirname ($src_file);
It might help to do move this line before the csv_tables meta initialization
(do global init before local init).
> my $sql = "SELECT File, Extension, Directory, Message from logs where Status
> = " .
> $dbh->quote ("ERROR") . " ORDER BY Time";
> my $sth = $dbh->prepare ( $sql );
> $sth->execute ();
>
> I turned on tracing (level 2) and according to the error message the file I’m
> trying to find isn’t being found.
>
> It looks like the query is ignoring the setting of “f_dir”. It’s instead
> looking for the file in the current directory, which isn’t what “f_dir”
> points to! (The trace acknowledges f_dir is pointing to the correct location)
>
> So if I manually run the code from the location where the log file is
> located, everything works.
>
> So I see one of two things being true:
> 1) “f_dir” is being ignored.
Only for table "logs", because logs's f_dir is initialized before you set it.
> 2) There is a problem with how I initialized things.
Indeed. You should really carefully study the Changes since DBI 1.49,
also for SQL::Statement since 1.405.
> Can anyone comment about which is the real issue? With the files I’m
> querying all over the place, putting chdir’s all over my code isn’t really a
> good option.
>
> Curtis Leach
> Lead Engineer
> RMS IT & ERM IT
> Phone: (702) 494-4562
> <image001.jpg>
>
>
> <dbitrace.log>
Cheers
--
Jens Rehsack
pkgsrc, Perl5
[email protected]