BeastForm - Introspect a database and dynamically generate models
version 0.000001
use BeastForm;
use Mojolicious::Lite;
get "/" => sub {
$_[0]->stash( drivers => BeastForm::drivers );
$_[0]->render( template => "form.html.ep" );
};
post "/" => sub {
my $db = BeastForm::driver( $_[0]->param( 'driver' ) )->connect(
$_[0]->param( 'db' ), $_[0]->param( 'username' ), $_[0]->param( 'password' )
)->read_with( 'BeastForm::Reader::SQLT' )
->write_with( 'BeastForm::Writer::DBIL::Dynamic' );
$_[0]->stash( posts => [ $db->table( 'posts' )->all ] );
$_[0]->render( template => "posts.html.ep" );
};
Because I want to distribute my next application as a single fatpacked script, I can't use the DBIx::Class (and the equally excellent DBIx::Class::Schema::Loader) which leaves me feeling like a sad panda. I know, I'll write some, I thought...
This library provides a means of connecting to a database (via DBIx::Connector), introspecting it and configuring your database wrappers appropriately. We will one day support spitting out module files like DBIx::Class::Schema::Loader
Think of us as the glue code that sorts out the tedious parts of dealing with databases for you so you can get on with building whatever you're working on!
For input, we currently support: * SQL::Translator (via BeastForm::Reader::SQLT)
For output, we currently support: * DBIx::Lite (via BeastForm::Writer::DBIL)
Database support is anything SQL::Translator supports, which is most things.
The primary mode of operation at the minute is 'dynamic'. This attempts to introspect your database and generate a schema for DBIL
We'd like to generate static pm files like DBIx::Class::Schema::Loader one day We'd also like scripts to automate the generation of static files from the shell
* Simple Moose-based API * Reasonable support for DBD::Pg * Introspects just about everything SQL::Translator does
* Better support for other databases (particularly SQLite) * Tests to run on everyone's machine. One day.
* Be packable with App::FatPacker (i.e. no XS, try and keep it small) * Favour simplicity and reusing existing cpan * Our (currently) preferred means of keeping an ordered hash is Hash::Ordered * Favour predictability. That means sorting hash keys etc.
It's easy and we're friendly.
1. Fork the repository on github 2. Check out your fork: git clone git@github.com:username/beastform.git && cd beastform
3. Make your changes 4. Add a remote for the upstream repository: git remote add upstream https://github.com/perl-spark
5. Rebase from master: git fetch upstream && git rebase upstream/master
6. File a pull Request!
Returns a hash of names to Driver objects
James Laver <james.laver@gmail.com>
Kent Fredric <kentnl@cpan.org>
This software is copyright (c) 2015 by James Laver on time generously donated by Anomalio.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.