Class::DBI::ClassGenerator - generate Class::DBI sub-class modules from a pre-exsting database's structure.
Yadda-yadda
This takes the following named parameters:
The name of the directory into which to drop the generated classes. If it doesn't exist it will be created. Sub-directories will be created under here as appropriate.
directory => 'lib'
An arrayref of the DSN, username and password to connect to the database.
connect_info => ['dbi:mysql:dbname', 'username', 'password']
The name of the base class that all your table classes will inherit their database connection from.
base_class => 'MyApp::DB'
A hashref whose keys are table names in the database and the values are the classnames you desire.
tables => { artists => 'MyApp::Artist', tracks => 'MyApp::Track', albums => 'MyApp::Album', ... }
If you leave this out, the code will assume that you want classes for all tables, and that their names should be generated thus:
The first character of the tablename is converted to uppercase; An underscore followed by a character becomes the character, in uppercase The base class name and :: is prepended.
This is probably a close approximation for what you want anyway.
It returns a list of all the files created.
This should be considered to be pre-production code. It's probably chock full of exciting bugs.
MySQL and SQLite are supported "out-of-the-box". Adding other databases is a simple matter of writing a "driver" module with two simple methods. You are encouraged to upload such modules to the CPAN yourself.
Class::DBI::ClassGenerator::Extending, for how to interrogate other databases.
Written by David Cantrell <david@cantrell.org.uk>
Copyright 2008-2009 Outcome Technologies Ltd
This software is free-as-in-speech software, and may be used, distributed, and modified under the terms of either the GNU General Public Licence version 2 or the Artistic Licence. It's up to you which one you use. The full text of the licences can be found in the files GPL2.txt and ARTISTIC.txt, respectively.
To install Class::DBI::ClassGenerator, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Class::DBI::ClassGenerator
CPAN shell
perl -MCPAN -e shell install Class::DBI::ClassGenerator
For more information on module installation, please visit the detailed CPAN module installation guide.