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

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 problem.pl 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:

673399.pl:

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(); # ... }

Print.csv:

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

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

Title:
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!
  • 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
  • Outside of code tags, you may need to use entities for some characters:
            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?
    Username:
    Password:

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

    How do I use this? | Other CB clients
    Other Users?
    Others romping around the Monastery: (15)
    As of 2014-11-24 15:25 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      My preferred Perl binaries come from:














      Results (143 votes), past polls