#!/usr/bin/perl use strict; use warnings; use DBI; # Connect to the database, (the directory containing our csv file(s)) my $dbh = DBI->connect("DBI:CSV:f_dir=.;csv_eol=\n;"); # Associate our csv file with the table name 'prospects' and # manually declare names for each of the columns $dbh->{'csv_tables'}->{'prospects.csv'} = { 'col_names' => ["name", "address", "floors", "donated", "contact"] }; # Output the name and number of floors using our column names my $sth = $dbh->prepare("SELECT * FROM prospects.csv WHERE name LIKE 'G%'"); $sth->execute(); while (my $row = $sth->fetchrow_hashref) { print("name = ", $row->{'name'}, ", Number of floors = ", $row->{'floors'}, "\n"); } $sth->finish(); #### DBD::CSV::st execute failed: Error 2034 while reading file /media/MicroSD/code/prospects.csv: EIF - Loose unescaped quote at /usr/local/share/perl/5.14.2/SQL/Statement.pm line 1055 [for Statement "SELECT * FROM prospects.csv WHERE name LIKE 'G%'"] at propects.pl line 20. DBD::CSV::st fetchrow_hashref failed: Attempt to fetch row without a preceeding execute () call or from a non-SELECT statement [for Statement "SELECT * FROM prospects.csv WHERE name LIKE 'G%'"] at propects.pl line 21.