
go ahead... be a heretic

Comment on


I'm getting an error with DBD::CSV, although it's actually thrown by SQL::Statement:

DBD::CSV::st execute failed: Execution ERROR: No such column 'PRINT."set"'. [for Statement " SELECT id, gid, card, "set", illus, num FROM Print "] at line 41.

SQL::Statement doesn't seem to recognize that "set" means set. Unfortunately, set must be quoted since it's a reserved word and SQL::Statement dies complaining of that fact when set is left unquoted.

Does anyone have any workarounds for this? Has this been fixed in a newer version? Looks like I'll have to first copy the CSV with different field names. Fortunately, the tool on which I am working is only used to import CSV into a "real database".

>perl -le"use SQL::Statement; print SQL::Statement->VERSION" 1.15 >perl -le"use DBD::CSV; print DBD::CSV->VERSION" 0.22

Code and data to reproduce:

use strict; use warnings; use DBI qw( ); use File::Spec::Functions qw( catfile ); { my $db = '.'; my $dsn = "dbi:CSV:f_dir=$db"; my $user = undef; my $passwd = undef; my $dbh = DBI->connect( $dsn, $user, $passwd, { RaiseError => 1, PrintError => 0, PrintWarn => 1, AutoCommit => 1, # No writing, so no need for +transactions. FetchHashKeyName => 'NAME_lc', } ); for (qw( Print )) { my $path = catfile($db, "$_.csv"); # Xyz and "Xyz" are erroneously considered different tables. $dbh->{csv_tables}{ $_ }{file} = $path; $dbh->{csv_tables}{qq{"$_"}}{file} = $path; } my $sth = $dbh->prepare(' SELECT id, gid, card, "set", illus, num FROM Print '); $sth->execute(); # ... }


id,gid,card,set,illus,num 1,1,1,1,"Foo Bar",1

In reply to SQL::Statement confusing literals and identifiers by ikegami

and:  <code> code here </code>

  • Please read these before you post! —
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Log In?

    What's my password?
    Create A New User
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others scrutinizing the Monastery: (2)
    As of 2014-03-17 05:52 GMT
    Find Nodes?
      Voting Booth?

      Have you used a cryptocurrency?

      Results (341 votes), past polls