2 DBIx::Class::Schema::Loader - Dynamic definition of a
7 use base qw/DBIx::Class::Schema::Loader/;
9 __PACKAGE__->load_from_connection(
10 dsn => "dbi:mysql:dbname",
13 additional_classes => [qw/DBIx::Class::Foo/],
14 additional_base_classes => [qw/My::Stuff/],
15 left_base_classes => [qw/DBIx::Class::Bar/],
16 constraint => '^foo.*',
18 options => { AutoCommit => 1 },
19 inflect => { child => 'children' },
23 # in seperate application code ...
27 my $schema1 = My::Schema->connect( $dsn, $user, $password, $attrs);
29 my $schema1 = "My::Schema";
30 # ^^ defaults to dsn/user/pass from load_from_connection()
32 # Get a list of the original (database) names of the tables that
34 my @tables = $schema1->loader->tables;
36 # Get a hashref of table_name => 'TableName' table-to-moniker
38 my $monikers = $schema1->loader->monikers;
40 # Get a hashref of table_name => 'My::Schema::TableName'
41 # table-to-classname mappings.
42 my $classes = $schema1->loader->classes;
44 # Use the schema as per normal for L<DBIx::Class::Schema>
45 my $rs = $schema1->resultset($monikers->{table_table})->search(...);
48 DBIx::Class::Schema::Loader automates the definition of a
49 DBIx::Class::Schema by scanning table schemas and setting up columns and
52 DBIx::Class::Schema::Loader supports MySQL, Postgres, SQLite and DB2.
53 See DBIx::Class::Schema::Loader::Generic for more, and
54 DBIx::Class::Schema::Loader::Writing for notes on writing your own
55 db-specific subclass for an unsupported db.
57 This module requires DBIx::Class::Loader 0.5 or later, and obsoletes
58 DBIx::Class::Loader for DBIx::Class version 0.5 and later.
62 Example in Synopsis above demonstrates the available arguments. For
63 detailed information on the arguments, see the
64 DBIx::Class::Schema::Loader::Generic documentation.
67 Brandon Black, "bblack@gmail.com"
69 Based on DBIx::Class::Loader by Sebastian Riedel
71 Based upon the work of IKEBE Tomohiro
74 Adam Anderson, Andy Grundman, Autrijus Tang, Dan Kubb, David Naughton,
75 Randal Schwartz, Simon Flack and all the others who've helped.
78 This library is free software; you can redistribute it and/or modify it
79 under the same terms as Perl itself.