in reply to Looking for elegant solution to dbi coding problem
The ?'s will handle the quoting for you, DBI is nice that way.$dbh->{RaiseError} = 1; my $sql = "INSERT INTO $table(".join(',',@fields).") VALUES(".join(',' +,(map{'?'}@fields)).")"; my $sth = $dbh->prepare($sql); #line by line from your file while(<INPUT>){ #do your split and execute here. $sth->execute((split /\t/,$_)); }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Looking for elegant solution to dbi coding problem
by Commander Salamander (Acolyte) on Jul 15, 2005 at 23:52 UTC | |
by graff (Chancellor) on Jul 16, 2005 at 05:40 UTC | |
by Commander Salamander (Acolyte) on Jul 16, 2005 at 18:26 UTC | |
by graff (Chancellor) on Jul 16, 2005 at 21:09 UTC | |
by planetscape (Chancellor) on Jul 16, 2005 at 16:05 UTC |