Class::DBI::Pg - Class::DBI extension for Postgres
use strict; use base qw(Class::DBI::Pg); __PACKAGE__->set_db(Main => 'dbi:Pg:dbname=dbname', 'user', 'password'); __PACKAGE__->set_up_table('film');
Class::DBI::Pg automate the setup of Class::DBI columns and primary key for Postgres.
select Postgres system catalog and find out all columns, primary key and SERIAL type column.
create table.
CREATE TABLE cd ( id SERIAL NOT NULL PRIMARY KEY, title TEXT, artist TEXT, release_date DATE );
setup your class.
package CD; use strict; use base qw(Class::DBI::Pg); __PACKAGE__->set_db(Main => 'dbi:Pg:dbname=db', 'user', 'password'); __PACKAGE__->set_up_table('cd');
This is almost the same as the following way.
package CD; use strict; use base qw(Class::DBI); __PACKAGE__->set_db(Main => 'dbi:Pg:dbname=db', 'user', 'password'); __PACKAGE__->table('cd'); __PACKAGE__->columns(Primary => 'id'); __PACKAGE__->columns(All => qw(id title artist release_date)); __PACKAGE__->sequence('cd_id_seq');
Declares the Class::DBI class specified by TABLENAME
Returns the postgres version that you are currently using.
Daisuke Maki dmaki@cpan.org
dmaki@cpan.org
Sebastian Riedel, sri@oook.de IKEBE Tomohiro, ikebe@edge.co.jp
sri@oook.de
ikebe@edge.co.jp
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
Class::DBI Class::DBI::mysql DBD::Pg
To install Class::DBI::Pg, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Class::DBI::Pg
CPAN shell
perl -MCPAN -e shell install Class::DBI::Pg
For more information on module installation, please visit the detailed CPAN module installation guide.