in reply to Extra quotes doing SQL insert from Perl to CSV.
Use placeholders and always_quote option
poj#!/usr/bin/perl use strict; use DBI; my $dbh = DBI->connect("dbi:CSV:", "", "",{ 'RaiseError' => 1 } ); $dbh->{'csv_tables'}->{'MyTable'} = { 'file' => 'data1.csv', 'col_names' => ["num","id"], 'always_quote' => 1, }; my $num = '0123'; my $id = '0124'; my $sql = "INSERT INTO MyTable VALUES (?,?)"; my $result = $dbh->do($sql,undef,$num,$id);
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Extra quotes doing SQL insert from Perl to CSV.
by JamieJ (Novice) on Oct 10, 2019 at 18:46 UTC |