Jifty::DBI::SchemaGenerator

Jifty::DBI::SchemaGenerator is a Perl module to generate table schemas from Jifty::DBI records.
Download

Jifty::DBI::SchemaGenerator Ranking & Summary

Advertisement

  • Rating:
  • License:
  • Perl Artistic License
  • Price:
  • FREE
  • Publisher Name:
  • David Glasser
  • Publisher web site:
  • http://search.cpan.org/~glasser/HTTP-Server-Simple-Recorder-0.02/lib/HTTP/Server/Simple/Recorder.pm

Jifty::DBI::SchemaGenerator Tags


Jifty::DBI::SchemaGenerator Description

Jifty::DBI::SchemaGenerator is a Perl module to generate table schemas from Jifty::DBI records. Jifty::DBI::SchemaGenerator is a Perl module to generate table schemas from Jifty::DBI records.This module turns a Jifty::Record object into an SQL schema for your chosen database. At the moment, your choices are MySQL, SQLite, or PostgreSQL. Oracle might also work right, though it's untested.SYNOPSISThe Short AnswerSee below for where we get the $handle and $model variables. use Jifty::DBI::SchemaGenerator; ... my $s_gen = Jifty::DBI::SchemaGenerator->new( $handle ); $s_gen->add_model($model); my @statements = $s_gen->create_table_sql_statements; print join("n", @statements, ''); ...The Long VersionSee Jifty::DBI for details about the first two parts.MyModel package MyModel; # lib/MyModel.pm use warnings; use strict; use base qw(Jifty::DBI::Record); # your custom code goes here. 1;MyModel::Schema package MyModel::Schema; # lib/MyModel/Schema.pm use warnings; use strict; use Jifty::DBI::Schema; column foo => type is 'text'; column bar => type is 'text'; 1;myscript.pl #!/usr/bin/env perl # myscript.pl use strict; use warnings; use Jifty::DBI::SchemaGenerator; use Jifty::DBI::Handle; use MyModel; use MyModel::Schema; my $handle = Jifty::DBI::Handle->new(); $handle->connect( driver => 'SQLite', database => 'testdb', ); my $model = MyModel->new($handle); my $s_gen = Jifty::DBI::SchemaGenerator->new( $handle ); $s_gen->add_model($model); # here's the basic point of this module: my @statements = $s_gen->create_table_sql_statements; print join("n", @statements, ''); # this part is directly from Jifty::Script::Schema::create_all_tables() $handle->begin_transaction; for my $statement (@statements) { my $ret = $handle->simple_query($statement); $ret or die "error creating a table: " . $ret->error_message; } $handle->commit; Requirements: · Perl


Jifty::DBI::SchemaGenerator Related Software