Subject: | Using "Primary key" leads to error |
Defining a PRIMARY KEY causes an error. You should parse it and forget
it. I want to use PRIMARY KEY in my script due to maintenance reasons.
This works:
#!/usr/bin/perl
use strict;
use warnings;
use DBI;
my $statement = q~CREATE TABLE test(test INT)~;
my $dbh =
DBI->connect("DBI:CSV:f_dir=/path/to/files/;csv_sep_char=\\;","","");
$dbh->do($statement);
But this code doesn't work:
#!/usr/bin/perl
use strict;
use warnings;
use DBI;
my $statement = q~CREATE TABLE test(test INT, PRIMARY KEY (test))~;
my $dbh =
DBI->connect("DBI:CSV:f_dir=/path/to/files/;csv_sep_char=\\;","","");
$dbh->do($statement);
I get the followin output:
~/entwicklung 42> perl dbd_csv_bug.pl
SQL ERROR: Bad table or column name 'PRIMARY' is a SQL reserved word!
Execution ERROR: No command found!.