1Class::DBI::Pg(3)     User Contributed Perl Documentation    Class::DBI::Pg(3)
2
3
4

NAME

6       Class::DBI::Pg - Class::DBI extension for Postgres
7

SYNOPSIS

9         use strict;
10         use base qw(Class::DBI::Pg);
11
12         __PACKAGE__->set_db(Main => 'dbi:Pg:dbname=dbname', 'user', 'password');
13         __PACKAGE__->set_up_table('film');
14

DESCRIPTION

16       Class::DBI::Pg automate the setup of Class::DBI columns and primary key
17       for Postgres.
18
19       select Postgres system catalog and find out all columns, primary key
20       and SERIAL type column.
21
22       create table.
23
24        CREATE TABLE cd (
25            id SERIAL NOT NULL PRIMARY KEY,
26            title TEXT,
27            artist TEXT,
28            release_date DATE
29        );
30
31       setup your class.
32
33        package CD;
34        use strict;
35        use base qw(Class::DBI::Pg);
36
37        __PACKAGE__->set_db(Main => 'dbi:Pg:dbname=db', 'user', 'password');
38        __PACKAGE__->set_up_table('cd');
39
40       This is almost the same as the following way.
41
42        package CD;
43
44        use strict;
45        use base qw(Class::DBI);
46
47        __PACKAGE__->set_db(Main => 'dbi:Pg:dbname=db', 'user', 'password');
48        __PACKAGE__->table('cd');
49        __PACKAGE__->columns(Primary => 'id');
50        __PACKAGE__->columns(All => qw(id title artist release_date));
51        __PACKAGE__->sequence('cd_id_seq');
52

METHODS

54   set_up_table TABLENAME HASHREF
55       Declares the Class::DBI class specified by TABLENAME. HASHREF can
56       specify options to when setting up the table.
57
58       ColumnGroup
59           You can specify the column group that you want your columns to be
60           in.
61
62              $class->set_up_table($table,  { ColumnGroup => 'Essential' });
63
64           The default is 'All'
65
66       Primary
67           Overrides primary key setting. This can be useful when working with
68           views instead of tables.
69
70   pg_version
71       Returns the postgres version that you are currently using.
72

AUTHOR

74       Daisuke Maki "dmaki@cpan.org"
75

AUTHOR EMERITUS

77       Sebastian Riedel, "sri@oook.de" IKEBE Tomohiro, "ikebe@edge.co.jp"
78

LICENSE

80       This library is free software; you can redistribute it and/or modify it
81       under the same terms as Perl itself.
82

SEE ALSO

84       Class::DBI Class::DBI::mysql DBD::Pg
85
86
87
88perl v5.34.0                      2022-01-21                 Class::DBI::Pg(3)
Impressum