use strict;
use DBI;
my $Usage = "$0 ";
my $db = DBI->connect("DBI:CSV:"); # use current working directory
$db->do("CREATE TABLE csv_test (id INTEGER, name CHAR(16))");
my $sth = $db->prepare("INSERT INTO csv_test (id,name) values (?,?)");
my @strings = ( "one \x{0661}",
"two \x{0662}",
"three \x{0663}" );
binmode STDOUT, ":utf8";
for (0..$#strings) {
printf "inserting %d,%s\n", $_+1, $strings[$_];
$sth->execute( $_+1, $strings[$_] );
}
$sth->finish();
$db->disconnect;
####
$sth = $db->prepare("SELECT * FROM csv_test");
$sth->execute;
while( my $row = $sth->fetchrow_arrayref ) {
printf "retrieved %d,%s\n", @$row;
}
$sth->finish;
####
$$row[1] = decode( "utf8", $$row[1] );
####
my @values = map { decode( "utf8", $_ ) } $sth->fetchrow_array;