The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

DBIx::Model - Build Perl objects of a database schema

VERSION

0.0.1_2 (2020-12-30)

SYNOPSIS

    use DBI;
    use DBIx::Model;

    my $dbh   = DBI->connect('dbi:SQLite:dbname=test.sqlite');
    my $model = $dbh->model;

    foreach my $table ( $model->tables ) {
        print $table->name . ' (' . $table->type . ")\n";
        foreach my $col ( $table->columns ) {
            print '  ' . $col->name;
            print ' ' . $col->type;
            print ' ' . ( $col->nullable ? '' : 'NOT NULL' );
            print "\n";
        }
    }

DESCRIPTION

DBIx::Model builds Perl objects that reflect a database's schema, using the standard table_info(), column_info(), foreign_key_info() and primary_key() methods from DBI.

INTERFACE

model( $catalog, $schema, $name, $type )

Takes exactly the same arguments as DBI::table_info() and method returns a DBIx::Model::DB object.

SEE ALSO

DBIx::Model::DB - database object holding tables.

DBIx::Model::Table - table objects holding columns and foreign key info

DBIx::Model::Column - column objects with references to foreign columns

DBIx::Model::FK - foreign key relationships

dbi2graphviz - create schema diagrams using GraphViz2.

AUTHOR

Mark Lawrence <nomad@null.net>

COPYRIGHT AND LICENSE

Copyright 2016,2020 Mark Lawrence <nomad@null.net>

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version.