After playing with your code and sample data for a bit, I had to conclude that the "BETWEEN ... AND ..." syntax is actually not supported by DBD::CSV. You can get the expected output by changing the query to:
SELECT * FROM perfmon WHERE Event_ID >= 7034 AND Event_ID <= 7037
(I'm not sure whether the "BETWEEN" values themselves are supposed to be part of the output set -- maybe you want ">" and "<".)

Here's a slightly cleaned up version of the OP code:

use strict; use DBI; my $query_string = "SELECT * FROM perfmon WHERE Event_ID >= 7034 and E +vent_ID <= 7037"; my $csv_file_name = "perfdata.csv"; my $csv_dbh; my $stmt_handle; $csv_dbh = DBI->connect( "DBI:CSV:", undef, undef, { csv_eol => "\n", csv_quote_char => "'", csv_tables => { perfmon => { file => $csv_file_n +ame }}, RaiseError => 1, } ) or die $!; $stmt_handle = $csv_dbh -> prepare( $query_string ); $stmt_handle -> execute(); while ( my @row = $stmt_handle->fetchrow_array() ) { my $rowstr = join(";", @row); print $rowstr,"\n"; } $stmt_handle -> finish(); $csv_dbh -> disconnect();
(The "csv_quote_char" spec seems appropriate given the sample data you posted; the "csv_eol" I'm using might be specific to my own download of the data.)

In reply to Re: DBI, CSV and SQL troubles by graff
in thread DBI, CSV and SQL troubles by Anonymous Monk

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!
  • 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, details, 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, summary, 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.