The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

Build Status

NAME

Teng - very simple DBI wrapper/ORMapper

SYNOPSIS

my $db = MyDB->new({ connect_info => [ 'dbi:SQLite:' ] });
my $row = $db->insert( 'table' => {
    col1 => $value
} );

DESCRIPTION

Teng is very simple DBI wrapper and simple O/R Mapper. It aims to be lightweight, with minimal dependencies so it's easier to install.

BASIC USAGE

create your db model base class.

package Your::Model;
use parent 'Teng';
1;

create your db schema class. See Teng::Schema for docs on defining schema class.

package Your::Model::Schema;
use Teng::Schema::Declare;
table {
    name 'user';
    pk 'id';
    columns qw( foo bar baz );
};
1;

in your script.

use Your::Model;

my $teng = Your::Model->new(\%args);
# insert new record.
my $row = $teng->insert('user',
    {
        id   => 1,
    }
);
$row->update({name => 'nekokak'}); # same do { $row->name('nekokak'); $row->update; }

$row = $teng->single_by_sql(q{SELECT id, name FROM user WHERE id = ?}, [ 1 ]);
$row->delete();

ARCHITECTURE

Teng classes are comprised of three distinct components:

MODEL

The model is where you say

package MyApp::Model;
use parent 'Teng';

This is the entry point to using Teng. You connect, insert, update, delete, select stuff using this object.

SCHEMA

The schema is a simple class that describes your table definitions. Note that this is different from DBIx::Class terms. DBIC's schema is equivalent to Teng's model + schema, where the actual schema information is scattered across the result classes.

In Teng, you simply use Teng::Schema's domain specific language to define a set of tables

package MyApp::Model::Schema;
use Teng::Schema::Declare;

table {
    name $table_name;
    pk $primary_key_column;
    columns qw(
        column1
        column2
        column3
    );
}

... and other tables ...

ROW

Unlike DBIx::Class, you don't need to have a set of classes that represent a row type (i.e. "result" classes in DBIC terms). In Teng, the row objects are blessed into anonymous classes that inherit from Teng::Row, so you don't have to create these classes if you just want to use some simple queries.

If you want to define methods to be performed by your row objects, simply create a row class like so:

package MyApp::Model::Row::Camelizedtable_name;
use parent qw(Teng::Row);

Note that your table name will be camelized.

METHODS

Teng provides a number of methods to all your classes,

TRIGGERS

Teng does not support triggers (NOTE: do not confuse it with SQL triggers - we're talking about Perl level triggers). If you really want to hook into the various methods, use something like Moose, Mouse, and Class::Method::Modifiers.

SEE ALSO

Fork

This module was forked from DBIx::Skinny, around version 0.0732. many incompatible changes have been made.

BUGS AND LIMITATIONS

No bugs have been reported.

AUTHORS

Atsushi Kobayashi <nekokak __at__ gmail.com>

Tokuhiro Matsuno tokuhirom@gmail.com

Daisuke Maki <daisuke@endeworks.jp>

SUPPORT

irc: #dbix-skinny@irc.perl.org

ML: http://groups.google.com/group/dbix-skinny

REPOSITORY

git clone git://github.com/nekokak/p5-teng.git  

LICENCE AND COPYRIGHT

Copyright (c) 2010, the Teng "AUTHOR". All rights reserved.

This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See perlartistic.