Class::DBI::Pg(3pm)
π Class::DBI::Pg β the manual, but make it cute π
okay bestie, so this is Class::DBI::Pg(3pm) β part of the User Contributed Perl Documentation, and it's literally the glow-up your Postgres + Class::DBI setup has been begging for. sit down, grab a strawberry drink π, and let's get into it.
β¨ NAME β¨
Class::DBI::Pg β a Class::DBI extension, but make it Postgres ππ
πΈ SYNOPSIS πΈ
like, here's the whole vibe in four lines:
use strict;
use base qw(Class::DBI::Pg);
__PACKAGE__->set_db(Main => 'dbi:Pg:dbname=dbname', 'user', 'password');
__PACKAGE__->set_up_table('film');
that's it. that's the post. β¨
π¦ DESCRIPTION π¦
so Class::DBI::Pg automates the setup of Class::DBI columns and primary key for Postgres. it justβ¦ does it for you. no cap. π₯
it selects the Postgres system catalog and finds out all the columns, the primary key, and any SERIAL type column. iykyk.
then you create the table, bestie:
CREATE TABLE cd (
id SERIAL NOT NULL PRIMARY KEY,
title TEXT,
artist TEXT,
release_date DATE
);
and then you set up 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');
and this is almost the same as doing it the long way, which looks like this:
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');
likeβ¦ the way you don't have to type all that anymore? iconic. main character energy fr fr. π
π METHODS π
π set_up_table TABLENAME HASHREF
declares the Class::DBI class specified by TABLENAME. and HASHREF? that's where you can specify options for when you're setting up the table. little customization moment. π«Ά
π ColumnGroup
you can specify the column group that you want your columns to be in, bestie:
$class->set_up_table($table, { ColumnGroup => 'Essential' });
the default is 'All' π«
π Primary
this one overrides the primary key setting. super useful when you're working with views instead of tables. yes, views. we love a plot twist. π
π pg_version
returns the postgres version that you are currently using. that's it, that's the whole method. short queen behavior. β
π AUTHOR π
Daisuke Maki "dmaki@cpan.org" β thank you for your service π«‘π
π AUTHOR EMERITUS π
Sebastian Riedel, "sri@oook.de" β and IKEBE Tomohiro, "ikebe@edge.co.jp" π
π LICENSE π
this library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. periodt. β¨
π₯ SEE ALSO π₯
Class::DBIClass::DBI::mysqlDBD::Pg
and that's the whole page, bestie!! πβ¨ this was perl v5.34.0, dated 2022-06-11, and it's giving Class::DBI::Pg(3pm) β go forth and slay your Postgres setup, no cap πππ
π¦ where this page comes from
- debian bookworm: libclass-dbi-pg-perl 0.09-6 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- debian trixie: libclass-dbi-pg-perl 0.09-6 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu noble: libclass-dbi-pg-perl 0.09-6 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu resolute: libclass-dbi-pg-perl 0.09-6 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: libclass-dbi-pg-perl 0.09-6 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms