#!/usr/local/bin/perl use strict; use warnings; use base qw/ Class::DBI /; my $dbname = "pure-ftpd"; my $user = "pure-ftpd"; my $pass = q(elided); my $host = "adjunct"; my $port = "5432"; main->connection("dbi:Pg:dbname=$dbname;host=$host;port=$port", $user, $pass, {FetchHashKeyName => 'NAME'}); # As pointed out by perrin, I tried with and # without the FetchHashKeyName flag. main->table('users'); main->columns(Primary => qw/ "User" /); main->columns(Others => qw/ "Password" "Uid" "Gid" "Dir" "ULBandwidth" "DLBandwidth" /); my $new = main->create ( { '"User"' => 'test', '"Password"' => 'foobarbaz', '"Uid"' => 5000, '"Gid"' => 5000, '"Dir"' => '/nonexistent', '"ULBandwidth"' => 5, '"DLBandwidth"' => 10 } ); #### Can't insert new main: DBD::Pg::st execute failed: ERROR: column "gid" of relation "users" does not exist [for Statement "INSERT INTO users ("gid", "dir", "ulbandwidth", "dlbandwidth", "uid", "user", "password") VALUES (?, ?, ?, ?, ?, ?, ?) "] at /usr/local/lib/perl5/site_perl/5.8.5/DBIx/ContextualFetch.pm line 51. at /usr/local/lib/perl5/site_perl/5.8.5/Class/DBI.pm line 233 Class::DBI::_croak('main=HASH(0x82edf90)', 'Can\'t insert new main: DBD::Pg::st execute failed: ERROR: c...', 'err', 'DBD::Pg::st execute failed: ERROR: column "gid" of relation ...', 'method', 'create') called at /usr/local/lib/perl5/site_perl/5.8.5/Class/DBI.pm line 644 Class::DBI::_insert_row('main=HASH(0x82edf90)', 'HASH(0x82f38a8)') called at /usr/local/lib/perl5/site_perl/5.8.5/Class/DBI.pm line 590 Class::DBI::_create('main', 'HASH(0x82e6b6c)') called at /usr/local/lib/perl5/site_perl/5.8.5/Class/DBI.pm line 470 Class::DBI::create('main', 'HASH(0x82e6998)') called at code/perl/playground/dbi/class1 line 13 #### Can't insert new main: DBD::Pg::st execute failed: ERROR: syntax error at or near "user" at character 61 [for Statement "INSERT INTO users (ulbandwidth, password, dlbandwidth, uid, user, gid, dir) VALUES (?, ?, ?, ?, ?, ?, ?) "] at /usr/local/lib/perl5/site_perl/5.8.5/DBIx/ContextualFetch.pm line 51. at /usr/local/lib/perl5/site_perl/5.8.5/Class/DBI.pm line 233 Class::DBI::_croak('main=HASH(0x82edf90)', 'Can\'t insert new main: DBD::Pg::st execute failed: ERROR: s...', 'err', 'DBD::Pg::st execute failed: ERROR: syntax error at or near "...', 'method', 'create') called at /usr/local/lib/perl5/site_perl/5.8.5/Class/DBI.pm line 644 Class::DBI::_insert_row('main=HASH(0x82edf90)', 'HASH(0x82f38a8)') called at /usr/local/lib/perl5/site_perl/5.8.5/Class/DBI.pm line 590 Class::DBI::_create('main', 'HASH(0x82e6b6c)') called at /usr/local/lib/perl5/site_perl/5.8.5/Class/DBI.pm line 470 Class::DBI::create('main', 'HASH(0x82e6998)') called at code/perl/playground/dbi/class1 line 13