Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"

Comment on

( #3333=superdoc: print w/replies, xml ) Need Help??

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

Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":

  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?

    What's my password?
    Create A New User
    and dust plays in a shaft of sunlight...

    How do I use this? | Other CB clients
    Other Users?
    Others examining the Monastery: (6)
    As of 2018-06-22 23:13 GMT
    Find Nodes?
      Voting Booth?
      Should cpanminus be part of the standard Perl release?

      Results (124 votes). Check out past polls.