スキーマの設定方法(Schema-Loader)

myapp.pl

 #!/usr/bin/env perl
 
 use strict;
 use warnings;
 use MyDB;
 
 my $db = MyDB->new;
 my $connect_info =
   { dsn => 'dbi:Pg:dbname=mydb;host=localhost', username => 'postgres', password => '' };
 $db->connect($connect_info);
 $db->schema->load_schema($connect_info);
 my $row = $db->search( 't1', { name => 'taro' } )->next;
 print $row->id . "\n";

MyDB.pm

 package MyDB;
 
 use strict;
 use warnings;
 use DBIx::Skinny;
 
 1;

MyDB/Schema.pm

 package MyDB::Schema;
 
 use strict;
 use warnings;
 use base qw/DBIx::Skinny::Schema::Loader/;
 use DBIx::Skinny::Schema;
 
 1;

トップ   新規 一覧 検索 最終更新   ヘルプ   最終更新のRSS