Plack::App::RapidApp::rDbic - Instant database CRUD using RapidApp
use Plack::App::RapidApp::rDbic; $app = Plack::App::RapidApp::rDbic->new({ connect_info => { dsn => 'dbi:SQLite:my_sqlt.db', user => '', password => '' } })->to_app; # Or, for an existing schema class: $app = Plack::App::RapidApp::rDbic->new({ schema_class => 'My::Schema', connect_info => { dsn => 'dbi:SQLite:my_sqlt.db', user => '', password => '' } })->to_app; # For an existing schema connection: my $schema = My::Schema->connect('dbi:SQLite:my_sqlt.db'); $app = Plack::App::RapidApp::rDbic->new({ schema => $schema })->to_app;
This module provides a Plack interface to a runtime-generated database CRUD application. It bootstraps and loads a fully working RapidApp application with a RapidDbic configuration for an arbitrary database, which can be supplied as either an existing DBIx::Class::Schema or a simple DBI connect string (dsn) to have DBIx::Class schema classes generated for you.
This module is used internally by rdbic.pl which exposes only a portion of the available options as a command-line script.
Your connect_info args normalized to hashref form (with dsn/user/password.) See "connect_info" in DBIx::Class::Storage::DBI for more info on the hashref form of "connect_info".
Alternative way to supply connect_info, as a string. The database user and password can be optionally inlined using commas.
connect_info
For example:
dsn => 'dbi:mysql:mydb,dbuser,dbpass'
Is equivalent to:
connect_info => ['dbi:mysql:mydb','dbuser','dbpass']
Is equivelent to:
connect_info => { dsn => 'dbi:mysql:mydb', user => 'dbuser', password => 'dbpass' }
Optional existing DBIx::Class::Schema class name. Leave unconfigured to have the schema classes generated on-the-fly using DBIx::Class::Schema::Loader.
Optional alternative existing/connected schema object. This option can be used instead of connect_info/schema_class.
schema_class
Name of the generated RapidApp/Catalyst app. Defaults to rDbicApp. When multiple instances are loaded, subsequent names are generated as rDbicApp1, rDbicApp2 and so on.
rDbicApp
rDbicApp1
rDbicApp2
One of five choices to broadly control CRUD interface behavior:
Default
Full CRUD is enabled with 'persist_immediately' turned off globally which means the user has to click "Save" to apply queued-up changes
Full CRUD is enabled with 'persist_immediately' turned on. Changes are applied as soon as the cell is blurred after making a change
Same as 'editable' except new rows are added directly to the grid instead of displaying an add record form
Same as 'edit-instant' except new rows are added directly to the grid; "Save" must still be clicked before the row is actually inserted
No create/update/delete interfaces at all (rapidapp.pl default)
For more fine-grained control, RapidDbic configs can also be applied in model_config.
model_config
Set to true to prevent the temp workdir from being cleaned up on exit (ignored when workdir is manually configured).
workdir
Defaults to false.
Parent temporary directory. Defaults to tmpdir from File::Spec (usually /tmp/)
tmpdir
/tmp/
Directory in which to generate temporary application files. If left unconfigured, this is an automatically generated directory 'rdbic-tmp-XXXXX' within tmpdir which is automatically cleaned/removed unless no_cleanup is true.
'rdbic-tmp-XXXXX'
no_cleanup
Set to true to override the location used for Catalyst temporary files to be contained within the workdir instead of within the system temp. This is useful to avoid leaving temporary files behind, but will slow startup because the asset files will be generated on each load.
Defaults to false, but set to true in the rdbic.pl script.
Directory to use for app_tmp when isolate_app_tmp is true. Defaults to tmp/ within the workdir
app_tmp
isolate_app_tmp
tmp/
Name of the Model::DBIC in the generated app. Defaults to an auto-generated name based on the schema/dsn
Model::DBIC
Optional extra config to apply to the Model::DBIC in the generated app. This is useful to be able to customize RapidDbic configs (See Catalyst::Plugin::RapidApp::RapidDbic)
PSGI $app CodeRef. Derives from Plack::Component
$app
Full class name of the Model::DBIC in the generated app.
Home directory for the generated RapidApp/Catalyst app. This will be the app name within the workdir
The temporary directory used by the generated RapidApp/Catalyst app. If isolate_app_tmp is true this will be within the workdir, or whatever directory is set in local_tmp. Otherwise it is the standard location returned by Catalyst::Utils::class2tempdir for the generated app (which is not cleaned up).
local_tmp
Catalyst::Utils::class2tempdir
Optional ArrayRef of loader_options which will be passed to the Schema::Loader. These should be supplied as a list of name=value pairs, for example:
loader_options => [qw/db_schema='%' generate_pod=1/]
This has the same effect as -o options supplied to dbicdump. For a complete list of suported options, see DBIx::Class::Schema::Loader::Base.
-o
Optional ArrayRef of connect_options to be added to the %extra_attributes of the connect_info. (See "connect_info" in DBIx::Class::Storage::DBI). Like loader_options, these should be supplied as a list of name=value pairs, for example:
%extra_attributes
loader_options
connect_options => [qw/quote_names=0 mysql_enable_utf8=0/]
Note: the options in the above example are both set to '1' by default (second only for MySQL). So the above example is how you would go about turning these options off if needed for some reason.
'1'
rdbic.pl
RapidApp
Plack::Component
Catalyst Advent 2014 - Day 16
Catalyst Advent 2014 - Day 17
Henry Van Styn <vanstyn@cpan.org>
This software is copyright (c) 2014 by IntelliTree Solutions llc.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
To install RapidApp, copy and paste the appropriate command in to your terminal.
cpanm
cpanm RapidApp
CPAN shell
perl -MCPAN -e shell install RapidApp
For more information on module installation, please visit the detailed CPAN module installation guide.