Class::DBI::DATA::Schema - Execute Class::DBI SQL from DATA sections
package Film.pm; use base 'Class::DBI'; # ... normal Class::DBI setup use 'Class::DBI::DATA::Schema'; Film->run_data_sql; __DATA__ CREATE TABLE IF NOT EXISTS film (....); REPLACE INTO film VALUES (...); REPLACE INTO film VALUES (...);
This is an extension to Class::DBI which injects a method into your class to find and execute all SQL statements in the DATA section of the package.
Film->run_data_sql;
Using this module will export a run_data_sql method into your class. This method will find SQL statements in the DATA section of the class it is called from, and execute them against the database that that class is set up to use.
It is safe to import this method into a Class::DBI subclass being used as the superclass for a range of classes.
WARNING: this does not do anything fancy to work out what is SQL. It merely assumes that everything in the DATA section is SQL, and applies each thing it finds (separated by semi-colons) in turn to your database. Similarly there is no security checking, or validation of the DATA in any way.
Copyright (C) 2003-2004 Kasei. All rights reserved.
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
Tony Bowden, <kasei@tmtm.com>.
Class::DBI.
To install Class::DBI::DATA::Schema, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Class::DBI::DATA::Schema
CPAN shell
perl -MCPAN -e shell install Class::DBI::DATA::Schema
For more information on module installation, please visit the detailed CPAN module installation guide.