#!/usr/bin/perl use strict; use warnings; use Class::DBI; # Declare a base class for us. Gallery::Class::DBI package Gallery::Class::DBI; use base 'Class::DBI'; Gallery::Class::DBI->set_db('Main', 'dbi:Pg:dbname=database', 'user','password'); # Basic image declaration. package Gallery::Image; use base 'Gallery::Class::DBI'; Gallery::Image->table('gallery_images'); Gallery::Image->columns(All => qw/id title author height width filename gallery/); # Do a creation. my $image = Gallery::Image->create({ title => 'Test', author => 1, height => 100, width => 100, filename => 'test.jpg', gallery => 1, }); $image->commit; #### CREATE TABLE gallery_images ( id SERIAL NOT NULL PRIMARY KEY, title TEXT, author INT NOT NULL, width INT, height INT, filename TEXT NOT NULL, gallery INT );