DBIx::DataModel::Schema::Generator(3)

NAME
DBIx::DataModel::Schema::Generator - automatically generate a schema for DBIx::DataModel

SYNOPSIS
  perl -MDBIx::DataModel::Schema::Generator      \
       -e "fromDBI('dbi:connection:string')" --  \
       -schema My::New::Schema > My/New/Schema.pm

  perl -MDBIx::DataModel::Schema::Generator      \
       -e "fromDBIxClass('Some::DBIC::Schema')" -- \
       -schema My::New::Schema > My/New/Schema.pm

If SQL::Translator is installed

  sqlt -f <parser> -t DBIx::DataModel::Schema::Generator <parser_input>

DESCRIPTION
Generates schema, table and association declarations for DBIx::DataModel, either from a DBI connection, or from an existing DBIx::Class schema. The result is written on standard output and can be redirected to a .pm file.

The module can be called easily from the perl command line, as demonstrated in the synopsis above. Command-line arguments after "--" are passed to method new.

Alternatively, if SQL::Translator is installed, you can use "DBIx::DataModel::Schema::Generator" as a producer, translating from any available "SQL::Translator" parser.

The generated code is a skeleton that most probably will need some manual additions or modifications to get a fully functional datamodel, because part of the information cannot be inferred automatically. In particular, you should inspect the names and multiplicities of the generated associations, and decide which of these associations should rather be compositions; and you should declare the column types for columns that need automatic inflation/deflation.

METHODS

  new
  my $generator = DBIx::DataModel::Schema::Generator->new(@args);

Creates a new instance of a schema generator. Functions fromDBI and fromDBIxClass automatically call "new" if necessary, so usually you do not need to call it yourself. Arguments are :

-schema
    Name of the DBIx::DataModel::Schema subclass that will be generated (default is "My::Schema").

  fromDBI
  $generator->fromDBI(@dbi_connexion_args);
  # or
  fromDBI(@dbi_connexion_args);

Connects to a DBI data source, gathers information from the database about tables, primary and foreign keys, and generates a "DBIx::DataModel" schema on standard output.

This can be used either as a regular method, or as a function (this function is exported by default). In the latter case, a generator is automatically created by calling new with arguments @ARGV.

DBI connection arguments are as in "connect" in DBI.

  fromDBIxClass
  $generator->fromDBIxClass('Some::DBIC::Schema');
  # or
  fromDBIxClass('Some::DBIC::Schema');

Loads an existing DBIx::Class schema, and translates its declarations into a "DBIx::DataModel" schema printed on standard output.

This can be used either as a regular method, or as a function (this function is exported by default). In the latter case, a generator is automatically created by calling new with arguments @ARGV.

  produce
Implementation of SQL::Translator::Producer.

AUTHOR
Laurent Dami, <laurent.dami AT etat geneve ch>

COPYRIGHT & LICENSE
Copyright 2008 Laurent Dami.

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