Dancer-Plugin-Database-2.09/0000755000175000017500000000000012255653600015102 5ustar davidpdavidpDancer-Plugin-Database-2.09/README0000644000175000017500000003265312255650304015771 0ustar davidpdavidpNAME Dancer::Plugin::Database - easy database connections for Dancer applications SYNOPSIS use Dancer; use Dancer::Plugin::Database; # Calling the database keyword will get you a connected database handle: get '/widget/view/:id' => sub { my $sth = database->prepare( 'select * from widgets where id = ?', ); $sth->execute(params->{id}); template 'display_widget', { widget => $sth->fetchrow_hashref }; }; # The handle is a Dancer::Plugin::Database::Core::Handle object, which subclasses # DBI's DBI::db handle and adds a few convenience features, for example: get '/insert/:name' => sub { database->quick_insert('people', { name => params->{name} }); }; get '/users/:id' => sub { template 'display_user', { person => database->quick_select('users', { id => params->{id} }), }; }; dance; Database connection details are read from your Dancer application config - see below. DESCRIPTION Provides an easy way to obtain a connected DBI database handle by simply calling the database keyword within your Dancer application Returns a Dancer::Plugin::Database::Core::Handle object, which is a subclass of DBI's `DBI::db' connection handle object, so it does everything you'd expect to do with DBI, but also adds a few convenience methods. See the documentation for Dancer::Plugin::Database::Core::Handle for full details of those. Takes care of ensuring that the database handle is still connected and valid. If the handle was last asked for more than `connection_check_threshold' seconds ago, it will check that the connection is still alive, using either the `$dbh->ping' method if the DBD driver supports it, or performing a simple no-op query against the database if not. If the connection has gone away, a new connection will be obtained and returned. This avoids any problems for a long-running script where the connection to the database might go away. Care is taken that handles are not shared across processes/threads, so this should be thread-safe with no issues with transactions etc. (Thanks to Matt S Trout for pointing out the previous lack of thread safety. Inspiration was drawn from DBIx::Connector.) CONFIGURATION Connection details will be taken from your Dancer application config file, and should be specified as, for example: plugins: Database: driver: 'mysql' database: 'test' host: 'localhost' port: 3306 username: 'myusername' password: 'mypassword' connection_check_threshold: 10 dbi_params: RaiseError: 1 AutoCommit: 1 on_connect_do: ["SET NAMES 'utf8'", "SET CHARACTER SET 'utf8'" ] log_queries: 1 handle_class: 'My::Super::Sexy::Database::Handle' The `connection_check_threshold' setting is optional, if not provided, it will default to 30 seconds. If the database keyword was last called more than this number of seconds ago, a quick check will be performed to ensure that we still have a connection to the database, and will reconnect if not. This handles cases where the database handle hasn't been used for a while and the underlying connection has gone away. The `dbi_params' setting is also optional, and if specified, should be settings which can be passed to `DBI->connect' as its fourth argument; see the DBI documentation for these. The optional `on_connect_do' setting is an array of queries which should be performed when a connection is established; if given, each query will be performed using `$dbh->do'. (If using MySQL, you might want to use this to set `SQL_MODE' to a suitable value to disable MySQL's built-in free data loss 'features', for example: on_connect_do: "SET SQL_MODE='TRADITIONAL'" (If you're not familiar with what I mean, I'm talking about the insane default behaviour of "hmm, this bit of data won't fit the column you're trying to put it in.. hmm, I know, I'll just munge it to fit, and throw a warning afterwards - it's not like you're relying on me to, y'know, store what you ask me to store". See http://effectivemysql.com/presentation/mysql-idiosyncrasies-that-bite/ for just one illustration. In hindsight, I wish I'd made a sensible `sql_mode' a default setting, but I don't want to change that now.) The optional `log_queries' setting enables logging of queries generated by the helper functions `quick_insert' et al in Dancer::Plugin::Database::Core::Handle. If you enable it, generated queries will be logged at 'debug' level. Be aware that they will contain the data you're passing to/from the database, so be careful not to enable this option in production, where you could inadvertently log sensitive information. If you prefer, you can also supply a pre-crafted DSN using the `dsn' setting; in that case, it will be used as-is, and the driver/database/host settings will be ignored. This may be useful if you're using some DBI driver which requires a peculiar DSN. The optional `handle_class' defines your own class into which database handles should be blessed. This should be a subclass of Dancer::Plugin::Database::Core::Handle (or DBI::db directly, if you just want to skip the extra features). You will require slightly different options depending on the database engine you're talking to. For instance, for SQLite, you won't need to supply `hostname', `port' etc, but will need to supply `database' as the name of the SQLite database file: plugins: Database: driver: SQLite database: 'foo.sqlite' For Oracle, you may want to pass `sid' (system ID) to identify a particular database, e.g.: plugins: Database: driver: Oracle host: localhost sid: ABC12 DEFINING MULTIPLE CONNECTIONS If you need to connect to multiple databases, this is easy - just list them in your config under `connections' as shown below: plugins: Database: connections: foo: driver: "SQLite" database: "foo.sqlite" bar: driver: "mysql" host: "localhost" .... Then, you can call the `database' keyword with the name of the database connection you want, for example: my $foo_dbh = database('foo'); my $bar_dbh = database('bar'); RUNTIME CONFIGURATION You can pass a hashref to the `database()' keyword to provide configuration details to override any in the config file at runtime if desired, for instance: my $dbh = database({ driver => 'SQLite', database => $filename }); (Thanks to Alan Haggai for this feature.) AUTOMATIC UTF-8 SUPPORT As of version 1.20, if your application is configured to use UTF-8 (you've defined the `charset' setting in your app config as `UTF-8') then support for UTF-8 for the database connection will be enabled, if we know how to do so for the database driver in use. If you do not want this behaviour, set `auto_utf8' to a false value when providing the connection details. GETTING A DATABASE HANDLE Calling `database' will return a connected database handle; the first time it is called, the plugin will establish a connection to the database, and return a reference to the DBI object. On subsequent calls, the same DBI connection object will be returned, unless it has been found to be no longer usable (the connection has gone away), in which case a fresh connection will be obtained. If you have declared named connections as described above in 'DEFINING MULTIPLE CONNECTIONS', then calling the database() keyword with the name of the connection as specified in the config file will get you a database handle connected with those details. You can also pass a hashref of settings if you wish to provide settings at runtime. CONVENIENCE FEATURES (quick_select, quick_update, quick_insert, quick_delete) The handle returned by the `database' keyword is a Dancer::Plugin::Database::Core::Handle object, which subclasses the `DBI::db' DBI connection handle. This means you can use it just like you'd normally use a DBI handle, but extra convenience methods are provided, as documented in the POD for Dancer::Plugin::Database::Core::Handle. Examples: # Quickly fetch the (first) row whose ID is 42 as a hashref: my $row = database->quick_select($table_name, { id => 42 }); # Fetch all badgers as an array of hashrefs: my @badgers = database->quick_select('animals', { genus => 'Mellivora' }); # Update the row where the 'id' column is '42', setting the 'foo' column to # 'Bar': database->quick_update($table_name, { id => 42 }, { foo => 'Bar' }); # Insert a new row, using a named connection (see above) database('connectionname')->quick_insert($table_name, { foo => 'Bar' }); # Delete the row with id 42: database->quick_delete($table_name, { id => 42 }); # Fetch all rows from a table (since version 1.30): database->quick_select($table_name, {}); There's more extensive documentation on these features in Dancer::Plugin::Database::Core::Handle, including using the `order_by', `limit', `columns' options to sort / limit results and include only specific columns. HOOKS This plugin uses Dancer's hooks support to allow you to register code that should execute at given times - for example: hook 'database_connected' => sub { my $dbh = shift; # do something with the new DB handle here }; Currrently defined hook positions are: `database_connected' Called when a new database connection has been established, after performing any `on_connect_do' statements, but before the handle is returned. Receives the new database handle as a parameter, so that you can do what you need with it. `database_connection_lost' Called when the plugin detects that the database connection has gone away. Receives the no-longer usable handle as a parameter, in case you need to extract some information from it (such as which server it was connected to). `database_connection_failed' Called when an attempt to connect to the database fails. Receives a hashref of connection settings as a parameter, containing the settings the plugin was using to connect (as obtained from the config file). `database_error' Called when a database error is raised by `DBI'. Receives two parameters: the error message being returned by DBI, and the database handle in question. If you need other hook positions which would be useful to you, please feel free to suggest them! AUTHOR David Precious, `' CONTRIBUTING This module is developed on Github at: http://github.com/bigpresh/Dancer-Plugin-Database Feel free to fork the repo and submit pull requests! Also, it makes sense to watch the repo on GitHub for updates. Feedback and bug reports are always appreciated. Even a quick mail to let me know the module is useful to you would be very nice - it's nice to know if code is being actively used. ACKNOWLEDGEMENTS Igor Bujna Franck Cuny Alan Haggai Christian Sánchez Michael Stiller Martin J Evans Carlos Sosa Matt S Trout Matthew Vickers Christian Walde Alberto Simões James Aitken (LoonyPandora) Mark Allen (mrallen1) Sergiy Borodych (bor) Mario Domgoergen (mdom) Andrey Inishev (inish777) Nick S. Knutov (knutov) Nicolas Franck (nicolasfranck) mscolly BUGS Please report any bugs or feature requests to `bug-dancer-plugin-database at rt.cpan.org', or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Dancer-Plugin-Database. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes. SUPPORT You can find documentation for this module with the perldoc command. perldoc Dancer::Plugin::Database You can also look for information at: * RT: CPAN's request tracker http://rt.cpan.org/NoAuth/Bugs.html?Dist=Dancer-Plugin-Database * AnnoCPAN: Annotated CPAN documentation http://annocpan.org/dist/Dancer-Plugin-Database * CPAN Ratings http://cpanratings.perl.org/d/Dancer-Plugin-Database * Search CPAN http://search.cpan.org/dist/Dancer-Plugin-Database/ You can find the author on IRC in the channel `#dancer' on . LICENSE AND COPYRIGHT Copyright 2010-12 David Precious. This program is free software; you can redistribute it and/or modify it under the terms of either: the GNU General Public License as published by the Free Software Foundation; or the Artistic License. See http://dev.perl.org/licenses/ for more information. SEE ALSO Dancer DBI Dancer::Plugin::SimpleCRUD Dancer-Plugin-Database-2.09/MANIFEST.SKIP0000644000175000017500000000025012255650304016773 0ustar davidpdavidp^\.git\/ maint ^tags$ .last_cover_stats Makefile$ ^blib ^pm_to_blib ^.*.bak ^.*.old ^t.*sessions ^cover_db ^.*\.log ^run_perltidy.sh$ ^.*\.swp$ ^ignore.txt ^.gitignore Dancer-Plugin-Database-2.09/t/0000755000175000017500000000000012255653600015345 5ustar davidpdavidpDancer-Plugin-Database-2.09/t/00-load.t0000644000175000017500000000042612255650304016666 0ustar davidpdavidp#!perl # had -T use Test::More import => ['!pass'], tests => 1; use Dancer; BEGIN { use_ok( 'Dancer::Plugin::Database' ) || print "Bail out! "; } diag( "Testing Dancer::Plugin::Database $Dancer::Plugin::Database::VERSION, with Dancer $Dancer::VERSION in Perl $], $^X" ); Dancer-Plugin-Database-2.09/t/pod.t0000644000175000017500000000035012255650304016310 0ustar davidpdavidp#!perl -T use strict; use warnings; use Test::More; # Ensure a recent version of Test::Pod my $min_tp = 1.22; eval "use Test::Pod $min_tp"; plan skip_all => "Test::Pod $min_tp required for testing POD" if $@; all_pod_files_ok(); Dancer-Plugin-Database-2.09/t/pod-coverage.t0000644000175000017500000000104712255650304020105 0ustar davidpdavidpuse strict; use warnings; use Test::More; # Ensure a recent version of Test::Pod::Coverage my $min_tpc = 1.08; eval "use Test::Pod::Coverage $min_tpc"; plan skip_all => "Test::Pod::Coverage $min_tpc required for testing POD coverage" if $@; # Test::Pod::Coverage doesn't require a minimum Pod::Coverage version, # but older versions don't recognize some common documentation styles my $min_pc = 0.18; eval "use Pod::Coverage $min_pc"; plan skip_all => "Pod::Coverage $min_pc required for testing POD coverage" if $@; all_pod_coverage_ok(); Dancer-Plugin-Database-2.09/t/lib/0000755000175000017500000000000012255653600016113 5ustar davidpdavidpDancer-Plugin-Database-2.09/t/lib/TestApp.pm0000644000175000017500000001530612255652663020046 0ustar davidpdavidppackage t::lib::TestApp; use Dancer; use Dancer::Plugin::Database; no warnings 'uninitialized'; hook database_connected => sub { my $dbh = shift; var(connecthookfired => $dbh); }; get '/connecthookfired' => sub { my $database = database(); # If the hook fired, it'll have squirreled away a reference to the DB handle # for us to look for. my $h = var('connecthookfired'); if (ref $h && $h->isa('DBI::db')) { return 1; } else { return 0; } }; my $last_db_error; hook 'database_error' => sub { $last_db_error = $_[0]; }; get '/errorhookfired' => sub { database->do('something silly'); return $last_db_error ? 1 : 0; }; get '/prepare_db' => sub { my @sql = ( q/create table users (id INTEGER, name VARCHAR, category VARCHAR)/, q/insert into users values (1, 'sukria', 'admin')/, q/insert into users values (2, 'bigpresh', 'admin')/, q/insert into users values (3, 'badger', 'animal')/, q/insert into users values (4, 'bodger', 'man')/, q/insert into users values (5, 'mousey', 'animal')/, q/insert into users values (6, 'mystery2', null)/, q/insert into users values (7, 'mystery1', null)/, ); database->do($_) for @sql; 'ok'; }; get '/' => sub { my $sth = database->prepare('select count(*) from users'); $sth->execute; my $total_users = $sth->fetch(); $total_users->[0]; }; get '/user/:id' => sub { my $sth = database->prepare('select * from users where id = ?'); $sth->execute( params->{id} ); my $user = $sth->fetch(); $user->[1] || "No such user"; }; del '/user/:id' => sub { my $sth = database->prepare('delete from users where id = ?'); $sth->execute( params->{id} ); 'ok'; }; # Routes to exercise some of the extended features: get '/quick_insert/:id/:name' => sub { database->quick_insert('users', { id => params->{id}, name => params->{name}, category => 'user' }, ); 'ok'; }; get '/quick_update/:id/:name' => sub { database->quick_update('users', { id => params->{id} }, { name => params->{name} }, ); 'ok'; }; get '/quick_delete/:id' => sub { database->quick_delete('users', { id => params->{id} }); 'ok'; }; get '/quick_select/:id' => sub { my $row = database->quick_select('users', { id => params->{id} }); return $row ? join(',', values %$row) : "No matching user"; }; get '/quick_select/:id/:parm' => sub { my $row = database->quick_select('users', { id => params->{id} }, [ 'id', params->{parm} ]); return $row ? join(',', values %$row) : "No matching user"; }; get '/quick_lookup/:name' => sub { my $id = database->quick_lookup('users', { name => params->{name} }, 'id'); return $id; }; get '/quick_count/:category' => sub { my $row = database->quick_count('users', { category => params->{category} }); return $row; }; get '/complex_where/:id' => sub { my $row = database->quick_select( 'users', { id => { 'gt' => params->{id} } } ); return $row ? join(',', values %$row) : "No matching user"; }; get '/complex_not/:id' => sub { my $row = database->quick_select('users', { category => { 'is' => undef, 'not' => 1 } }); return $row ? join(',', values %$row) : "No matching user"; }; get '/set_op/:id' => sub { my $row = database->quick_select('users', { id => [ params->{id} ] }); return $row ? join(',', values %$row) : "No matching user"; }; get '/quick_select_many' => sub { my @users = database->quick_select('users', { category => 'admin' }); return join ',', sort map { $_->{name} } @users; }; # e.g. /quick_select_specific_cols/foo should return col 'foo' # or /quick_select_specific_cols/foo/bar returns foo:bar get '/quick_select_specific_cols/**' => sub { my $out; my $cols = (splat)[0]; my @users = database->quick_select('users', {}, { columns => $cols }); for my $user (@users) { $out .= join(':', @$user{@$cols}) . "\n"; } return $out; }; get '/quick_select_with_limit/:limit' => sub { my $limit = params->{limit}; my @users = database->quick_select('users', {}, { limit => $limit }); return scalar @users; }; get '/quick_select_sorted' => sub { my @users = database->quick_select('users', {}, { order_by => 'name' }); return join ':', map { $_->{name} } @users; }; get '/quick_select_sorted_rev' => sub { my @users = database->quick_select( 'users', {}, { order_by => { desc => 'name' } } ); return join ':', map { $_->{name} } @users; }; get '/quick_select_sorted_where' => sub { my @users = database->quick_select( 'users', { category => undef }, { order_by => 'name' } ); return join ':', map { $_->{name} } @users; }; # Check we can get a handle by passing a hashref of settings, too: get '/runtime_config' => sub { my $dbh = database({ driver => 'SQLite', database => ':memory:'}); $dbh ? 'ok' : ''; }; # Check we get the same handle each time we call database() get '/handles_cached' => sub { database() eq database() and return "Same handle returned"; }; get '/handles_cached_after_reconnect' => sub { my $old_handle = database(); $old_handle->disconnect; my $new_handle = database(); if ($old_handle ne $new_handle && $new_handle eq database()) { return "New handle cached after reconnect"; } }; # Check that the database_connection_lost hook fires when we force a db handle # to go away: hook database_connection_lost => sub { var(lost_connection => 1); }; get '/database_connection_lost_fires' => sub { var(lost_connection => 0); database()->disconnect; # We set connection_check_threshold to 0.1 at the start, so wait a second # then check that the code detects the handle is no longer connected and # triggers the hook sleep 1; my $handle = database(); return var('lost_connection'); }; # Check that database_connection_failed hook fires if we can't connect - pass # bogus connection details to make that happen hook database_connection_failed => sub { var connection_failed => 1; }; get '/database_connection_failed_fires' => sub { # Give a ridiculous database filename which should never exist in order to # force a connection failure my $handle = database({ dsn => "dbi:SQLite:/Please/Tell/Me/This/File/Does/Not/Exist!", dbi_params => { HandleError => sub { return 0 }, # gobble connect failed message RaiseError => 0, PrintError => 0, }, }); return var 'connection_failed'; }; # Check that the handle isa() subclass of the named class get '/isa/:class' => sub { return database->isa(params->{class}) ? 1 : 0; }; 1; Dancer-Plugin-Database-2.09/t/lib/views/0000755000175000017500000000000012255653600017250 5ustar davidpdavidpDancer-Plugin-Database-2.09/t/lib/views/.placeholder0000644000175000017500000000052212255650304021530 0ustar davidpdavidpThis directory is empty on purpose, and this file is here solely so that git tracks it, as git won't track empty directories (mostly because it doesn't track directories at all, only the files in them). This otherwise-empty directory is needed to avoid a strange bug on Windows systems where Cwd::realpath() croaks if they don't exist. Dancer-Plugin-Database-2.09/t/lib/public/0000755000175000017500000000000012255653600017371 5ustar davidpdavidpDancer-Plugin-Database-2.09/t/lib/public/.placeholder0000644000175000017500000000052212255650304021651 0ustar davidpdavidpThis directory is empty on purpose, and this file is here solely so that git tracks it, as git won't track empty directories (mostly because it doesn't track directories at all, only the files in them). This otherwise-empty directory is needed to avoid a strange bug on Windows systems where Cwd::realpath() croaks if they don't exist. Dancer-Plugin-Database-2.09/t/lib/lib/0000755000175000017500000000000012255653600016661 5ustar davidpdavidpDancer-Plugin-Database-2.09/t/lib/lib/.placeholder0000644000175000017500000000052212255650304021141 0ustar davidpdavidpThis directory is empty on purpose, and this file is here solely so that git tracks it, as git won't track empty directories (mostly because it doesn't track directories at all, only the files in them). This otherwise-empty directory is needed to avoid a strange bug on Windows systems where Cwd::realpath() croaks if they don't exist. Dancer-Plugin-Database-2.09/t/lib/lib/TestHandleClass.pm0000644000175000017500000000011712255650304022235 0ustar davidpdavidppackage TestHandleClass; use base 'Dancer::Plugin::Database::Core::Handle'; 1; Dancer-Plugin-Database-2.09/t/01-basic.t0000644000175000017500000001434512255652663017050 0ustar davidpdavidpuse strict; use warnings; use Test::More import => ['!pass']; use t::lib::TestApp; use Dancer ':syntax'; use Dancer::Test; eval { require DBD::SQLite }; if ($@) { plan skip_all => 'DBD::SQLite required to run these tests'; } plan tests => 43; my $dsn = "dbi:SQLite:dbname=:memory:"; my $conf = { Database => { dsn => $dsn, connection_check_threshold => 0.1, dbi_params => { RaiseError => 0, PrintError => 0, PrintWarn => 0, }, handle_class => 'TestHandleClass', } }; set plugins => $conf; set logger => 'capture'; set log => 'debug'; response_content_is [ GET => '/connecthookfired' ], 1, 'database_connected hook fires'; response_content_is [ GET => '/errorhookfired' ], 1, 'database_error hook fires'; response_content_is [ GET => '/isa/DBI::db' ], 1, "handle isa('DBI::db')"; response_content_is [ GET => '/isa/Dancer::Plugin::Database::Core::Handle' ], 1, "handle isa('Dancer::Plugin::Database::Core::Handle')"; response_content_is [ GET => '/isa/TestHandleClass' ], 1, "handle isa('TestHandleClass')"; response_content_is [ GET => '/isa/duck' ], 0, # reverse duck-typing ;) "handle is not a duck"; response_status_is [ GET => '/prepare_db' ], 200, 'db is created'; response_status_is [ GET => '/' ], 200, "GET / is found"; response_content_like [ GET => '/' ], qr/7/, "content looks good for / (7 users afiter DB initialisation)"; response_status_is [ GET => '/user/1' ], 200, 'GET /user/1 is found'; response_content_like [ GET => '/user/1' ], qr/sukria/, 'content looks good for /user/1'; response_content_like [ GET => '/user/2' ], qr/bigpresh/, "content looks good for /user/2"; response_status_is [ DELETE => '/user/3' ], 200, 'DELETE /user/3 is ok'; response_content_like [ GET => '/' ], qr/6/, 'content looks good for / (6 users after deleting one)'; # Exercise the extended features (quick_update et al) response_status_is [ GET => '/quick_insert/42/Bob' ], 200, "quick_insert returned OK status"; response_content_like [ GET => '/user/42' ], qr/Bob/, "quick_insert created a record successfully"; response_content_like [ GET => '/quick_select/42' ], qr/Bob/, "quick_select returned the record created by quick_insert"; response_content_unlike [ GET => '/quick_select/69' ], qr/Bob/, "quick_select doesn't return non-matching record"; response_content_like [ GET => '/quick_select/1/category' ], qr/admin/, 'content looks good for /quick_select/1/category'; response_content_like [ GET => '/quick_select/2/name' ], qr/bigpresh/, 'content looks good for /quick_select/2/name'; response_content_like [ GET => '/quick_lookup/bigpresh' ], qr/2/, 'content looks good for /quick_lookup/bigpresh'; # Test quick_count functions response_content_is [ GET => '/quick_count/admin'], 2, 'quick_count shows 2 admins'; response_content_like [ GET => '/complex_where/4' ], qr/mousey/, "Complex where clause succeeded"; response_content_like [ GET => '/complex_not/42' ], qr/sukria/, "Complex not where clause succeeded"; response_content_like [ GET => '/set_op/2' ], qr/bigpresh/, "set operation where clause succeeded"; response_content_like [ GET => '/quick_select_many' ], qr/\b bigpresh,sukria \b/x, "quick_select returns multiple records in list context"; response_status_is [ GET => '/quick_update/42/Billy' ], 200, "quick_update returned OK status"; response_content_like [ GET => '/user/42' ], qr/Billy/, "quick_update updated a record successfully"; response_status_is [ GET => '/quick_delete/42' ], 200, "quick_delete returned OK status"; response_content_like [ GET => '/user/42' ], qr/No such user/, "quick_delete deleted a record successfully"; # Test that we can fetch only the columns we want response_content_like [ GET => '/quick_select_specific_cols/name' ], qr/^bigpresh$/m, 'Fetched a single specified column OK'; response_content_like [ GET => '/quick_select_specific_cols/name/category' ], qr/^bigpresh:admin$/m, 'Fetched multiple specified columns OK'; # Test that we can limit the number of rows we get back: response_content_is [ GET => '/quick_select_with_limit/1'], "1", "User-specified LIMIT works (1 row)"; response_content_is [ GET => '/quick_select_with_limit/2'], "2", "User-specified LIMIT works (2 row)"; # Test that order_by gives us rows in desired order response_content_is [ GET => '/quick_select_sorted' ], "bigpresh:bodger:mousey:mystery1:mystery2:sukria", "Records sorted properly"; response_content_is [ GET => '/quick_select_sorted_rev' ], "sukria:mystery2:mystery1:mousey:bodger:bigpresh", "Records sorted properly in descending order"; # Use where and order_by together # This didn't work as the WHERE and ORDER BY clauses were concatenated without # a space, as per https://github.com/bigpresh/Dancer-Plugin-Database/pull/27 response_content_is [ GET => '/quick_select_sorted_where' ], "mystery1:mystery2"; # Test that runtime configuration gives us a handle, too: response_status_is [ GET => '/runtime_config' ], 200, "runtime_config returned OK status"; response_content_like [ GET => '/runtime_config' ], qr/ok/, "runtime_config got a usable database handle"; # Test that we get the same handle each time we call the database() keyword # (i.e., that handles are cached appropriately) response_content_like [ GET => '/handles_cached' ], qr/Same handle returned/; # ... and that we get the same handle each time we call the database() keyword # after a reconnection (see PR-44) response_content_like [ GET => '/handles_cached_after_reconnect' ], qr/New handle cached after reconnect/; # Test that the database_connection_lost hook fires when the connection goes # away response_content_is [ GET => '/database_connection_lost_fires' ], 1, 'database_connection_lost hook fires'; # Test that the database_connection_failed hook fires when we can't connect response_content_is [ GET => '/database_connection_failed_fires' ], 1, 'database_connection_failed hook fires'; Dancer-Plugin-Database-2.09/t/manifest.t0000644000175000017500000000042012255650304017332 0ustar davidpdavidp#!perl -T use strict; use warnings; use Test::More; unless ( $ENV{RELEASE_TESTING} ) { plan( skip_all => "Author tests not required for installation" ); } eval "use Test::CheckManifest 0.9"; plan skip_all => "Test::CheckManifest 0.9 required" if $@; ok_manifest(); Dancer-Plugin-Database-2.09/META.json0000644000175000017500000000243612255653600016530 0ustar davidpdavidp{ "abstract" : "easy database connections for Dancer applications", "author" : [ "David Precious " ], "dynamic_config" : 1, "generated_by" : "ExtUtils::MakeMaker version 6.82, CPAN::Meta::Converter version 2.120351", "license" : [ "perl_5" ], "meta-spec" : { "url" : "http://search.cpan.org/perldoc?CPAN::Meta::Spec", "version" : "2" }, "name" : "Dancer-Plugin-Database", "no_index" : { "directory" : [ "t", "inc" ] }, "prereqs" : { "build" : { "requires" : { "ExtUtils::MakeMaker" : "0" } }, "configure" : { "requires" : { "ExtUtils::MakeMaker" : "0" } }, "runtime" : { "requires" : { "Dancer" : "1.3099", "Dancer::Plugin::Database::Core" : "0.04", "Test::More" : "0" } } }, "release_status" : "stable", "resources" : { "bugtracker" : { "web" : "https://github.com/bigpresh/Dancer-Plugin-Database/issues" }, "homepage" : "https://github.com/bigpresh/Dancer-Plugin-Database/", "repository" : { "url" : "https://github.com/bigpresh/Dancer-Plugin-Database" } }, "version" : "2.09" } Dancer-Plugin-Database-2.09/META.yml0000644000175000017500000000143112255653600016352 0ustar davidpdavidp--- abstract: 'easy database connections for Dancer applications' author: - 'David Precious ' build_requires: ExtUtils::MakeMaker: 0 configure_requires: ExtUtils::MakeMaker: 0 dynamic_config: 1 generated_by: 'ExtUtils::MakeMaker version 6.82, CPAN::Meta::Converter version 2.120351' license: perl meta-spec: url: http://module-build.sourceforge.net/META-spec-v1.4.html version: 1.4 name: Dancer-Plugin-Database no_index: directory: - t - inc requires: Dancer: 1.3099 Dancer::Plugin::Database::Core: 0.04 Test::More: 0 resources: bugtracker: https://github.com/bigpresh/Dancer-Plugin-Database/issues homepage: https://github.com/bigpresh/Dancer-Plugin-Database/ repository: https://github.com/bigpresh/Dancer-Plugin-Database version: 2.09 Dancer-Plugin-Database-2.09/lib/0000755000175000017500000000000012255653600015650 5ustar davidpdavidpDancer-Plugin-Database-2.09/lib/Dancer/0000755000175000017500000000000012255653600017044 5ustar davidpdavidpDancer-Plugin-Database-2.09/lib/Dancer/Plugin/0000755000175000017500000000000012255653600020302 5ustar davidpdavidpDancer-Plugin-Database-2.09/lib/Dancer/Plugin/Database.pm0000644000175000017500000003375112255653345022363 0ustar davidpdavidppackage Dancer::Plugin::Database; use strict; use Dancer::Plugin::Database::Core; use Dancer::Plugin::Database::Core::Handle; use Dancer ':syntax'; use Dancer::Plugin; =encoding utf8 =head1 NAME Dancer::Plugin::Database - easy database connections for Dancer applications =cut our $VERSION = '2.09'; my $settings = undef; sub _load_db_settings { $settings = plugin_setting(); $settings->{charset} ||= setting('charset'); } sub _logger { Dancer::Logger->can( $_[0] )->( $_[1] ) } sub _execute_hook { execute_hook(@_) } register database => sub { _load_db_settings() unless $settings; my ($dbh, $cfg) = Dancer::Plugin::Database::Core::database( arg => $_[0], logger => \&_logger, hook_exec => \&_execute_hook, settings => $settings ); $settings = $cfg; return $dbh; }; register_hook(qw(database_connected database_connection_lost database_connection_failed database_error)); register_plugin; =head1 SYNOPSIS use Dancer; use Dancer::Plugin::Database; # Calling the database keyword will get you a connected database handle: get '/widget/view/:id' => sub { my $sth = database->prepare( 'select * from widgets where id = ?', ); $sth->execute(params->{id}); template 'display_widget', { widget => $sth->fetchrow_hashref }; }; # The handle is a Dancer::Plugin::Database::Core::Handle object, which subclasses # DBI's DBI::db handle and adds a few convenience features, for example: get '/insert/:name' => sub { database->quick_insert('people', { name => params->{name} }); }; get '/users/:id' => sub { template 'display_user', { person => database->quick_select('users', { id => params->{id} }), }; }; dance; Database connection details are read from your Dancer application config - see below. =head1 DESCRIPTION Provides an easy way to obtain a connected DBI database handle by simply calling the database keyword within your L application Returns a L object, which is a subclass of L's C connection handle object, so it does everything you'd expect to do with DBI, but also adds a few convenience methods. See the documentation for L for full details of those. Takes care of ensuring that the database handle is still connected and valid. If the handle was last asked for more than C seconds ago, it will check that the connection is still alive, using either the C<< $dbh->ping >> method if the DBD driver supports it, or performing a simple no-op query against the database if not. If the connection has gone away, a new connection will be obtained and returned. This avoids any problems for a long-running script where the connection to the database might go away. Care is taken that handles are not shared across processes/threads, so this should be thread-safe with no issues with transactions etc. (Thanks to Matt S Trout for pointing out the previous lack of thread safety. Inspiration was drawn from DBIx::Connector.) =head1 CONFIGURATION Connection details will be taken from your Dancer application config file, and should be specified as, for example: plugins: Database: driver: 'mysql' database: 'test' host: 'localhost' port: 3306 username: 'myusername' password: 'mypassword' connection_check_threshold: 10 dbi_params: RaiseError: 1 AutoCommit: 1 on_connect_do: ["SET NAMES 'utf8'", "SET CHARACTER SET 'utf8'" ] log_queries: 1 handle_class: 'My::Super::Sexy::Database::Handle' The C setting is optional, if not provided, it will default to 30 seconds. If the database keyword was last called more than this number of seconds ago, a quick check will be performed to ensure that we still have a connection to the database, and will reconnect if not. This handles cases where the database handle hasn't been used for a while and the underlying connection has gone away. The C setting is also optional, and if specified, should be settings which can be passed to C<< DBI->connect >> as its fourth argument; see the L documentation for these. The optional C setting is an array of queries which should be performed when a connection is established; if given, each query will be performed using C<< $dbh->do >>. (If using MySQL, you might want to use this to set C to a suitable value to disable MySQL's built-in free data loss 'features', for example: on_connect_do: "SET SQL_MODE='TRADITIONAL'" (If you're not familiar with what I mean, I'm talking about the insane default behaviour of "hmm, this bit of data won't fit the column you're trying to put it in.. hmm, I know, I'll just munge it to fit, and throw a warning afterwards - it's not like you're relying on me to, y'know, store what you ask me to store". See L for just one illustration. In hindsight, I wish I'd made a sensible C a default setting, but I don't want to change that now.) The optional C setting enables logging of queries generated by the helper functions C et al in L. If you enable it, generated queries will be logged at 'debug' level. Be aware that they will contain the data you're passing to/from the database, so be careful not to enable this option in production, where you could inadvertently log sensitive information. If you prefer, you can also supply a pre-crafted DSN using the C setting; in that case, it will be used as-is, and the driver/database/host settings will be ignored. This may be useful if you're using some DBI driver which requires a peculiar DSN. The optional C defines your own class into which database handles should be blessed. This should be a subclass of L (or L directly, if you just want to skip the extra features). You will require slightly different options depending on the database engine you're talking to. For instance, for SQLite, you won't need to supply C, C etc, but will need to supply C as the name of the SQLite database file: plugins: Database: driver: SQLite database: 'foo.sqlite' For Oracle, you may want to pass C (system ID) to identify a particular database, e.g.: plugins: Database: driver: Oracle host: localhost sid: ABC12 =head2 DEFINING MULTIPLE CONNECTIONS If you need to connect to multiple databases, this is easy - just list them in your config under C as shown below: plugins: Database: connections: foo: driver: "SQLite" database: "foo.sqlite" bar: driver: "mysql" host: "localhost" .... Then, you can call the C keyword with the name of the database connection you want, for example: my $foo_dbh = database('foo'); my $bar_dbh = database('bar'); =head1 RUNTIME CONFIGURATION You can pass a hashref to the C keyword to provide configuration details to override any in the config file at runtime if desired, for instance: my $dbh = database({ driver => 'SQLite', database => $filename }); (Thanks to Alan Haggai for this feature.) =head1 AUTOMATIC UTF-8 SUPPORT As of version 1.20, if your application is configured to use UTF-8 (you've defined the C setting in your app config as C) then support for UTF-8 for the database connection will be enabled, if we know how to do so for the database driver in use. If you do not want this behaviour, set C to a false value when providing the connection details. =head1 GETTING A DATABASE HANDLE Calling C will return a connected database handle; the first time it is called, the plugin will establish a connection to the database, and return a reference to the DBI object. On subsequent calls, the same DBI connection object will be returned, unless it has been found to be no longer usable (the connection has gone away), in which case a fresh connection will be obtained. If you have declared named connections as described above in 'DEFINING MULTIPLE CONNECTIONS', then calling the database() keyword with the name of the connection as specified in the config file will get you a database handle connected with those details. You can also pass a hashref of settings if you wish to provide settings at runtime. =head1 CONVENIENCE FEATURES (quick_select, quick_update, quick_insert, quick_delete, quick_count) The handle returned by the C keyword is a L object, which subclasses the C DBI connection handle. This means you can use it just like you'd normally use a DBI handle, but extra convenience methods are provided, as documented in the POD for L. Examples: # Quickly fetch the (first) row whose ID is 42 as a hashref: my $row = database->quick_select($table_name, { id => 42 }); # Fetch all badgers as an array of hashrefs: my @badgers = database->quick_select('animals', { genus => 'Mellivora' }); # Update the row where the 'id' column is '42', setting the 'foo' column to # 'Bar': database->quick_update($table_name, { id => 42 }, { foo => 'Bar' }); # Insert a new row, using a named connection (see above) database('connectionname')->quick_insert($table_name, { foo => 'Bar' }); # Delete the row with id 42: database->quick_delete($table_name, { id => 42 }); # Fetch all rows from a table (since version 1.30): database->quick_select($table_name, {}); # Retrieve a count of rows matching the criteria: database->quick_count($table_name, {}); There's more extensive documentation on these features in L, including using the C, C, C options to sort / limit results and include only specific columns. =head1 HOOKS This plugin uses Dancer's hooks support to allow you to register code that should execute at given times - for example: hook 'database_connected' => sub { my $dbh = shift; # do something with the new DB handle here }; Currrently defined hook positions are: =over 4 =item C Called when a new database connection has been established, after performing any C statements, but before the handle is returned. Receives the new database handle as a parameter, so that you can do what you need with it. =item C Called when the plugin detects that the database connection has gone away. Receives the no-longer usable handle as a parameter, in case you need to extract some information from it (such as which server it was connected to). =item C Called when an attempt to connect to the database fails. Receives a hashref of connection settings as a parameter, containing the settings the plugin was using to connect (as obtained from the config file). =item C Called when a database error is raised by C. Receives two parameters: the error message being returned by DBI, and the database handle in question. =back If you need other hook positions which would be useful to you, please feel free to suggest them! =head1 AUTHOR David Precious, C<< >> =head1 CONTRIBUTING This module is developed on Github at: L Feel free to fork the repo and submit pull requests! Also, it makes sense to L on GitHub for updates. Feedback and bug reports are always appreciated. Even a quick mail to let me know the module is useful to you would be very nice - it's nice to know if code is being actively used. =head1 ACKNOWLEDGEMENTS Igor Bujna Franck Cuny Alan Haggai Christian Sánchez Michael Stiller Martin J Evans Carlos Sosa Matt S Trout Matthew Vickers Christian Walde Alberto Simões James Aitken (LoonyPandora) Mark Allen (mrallen1) Sergiy Borodych (bor) Mario Domgoergen (mdom) Andrey Inishev (inish777) Nick S. Knutov (knutov) Nicolas Franck (nicolasfranck) mscolly =head1 BUGS Please report any bugs or feature requests to C, or through the web interface at L. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes. =head1 SUPPORT You can find documentation for this module with the perldoc command. perldoc Dancer::Plugin::Database You can also look for information at: =over 4 =item * RT: CPAN's request tracker L =item * AnnoCPAN: Annotated CPAN documentation L =item * CPAN Ratings L =item * Search CPAN L =back You can find the author on IRC in the channel C<#dancer> on . =head1 LICENSE AND COPYRIGHT Copyright 2010-12 David Precious. This program is free software; you can redistribute it and/or modify it under the terms of either: the GNU General Public License as published by the Free Software Foundation; or the Artistic License. See http://dev.perl.org/licenses/ for more information. =head1 SEE ALSO L L L =cut 1; # End of Dancer::Plugin::Database Dancer-Plugin-Database-2.09/MANIFEST0000644000175000017500000000065712255653600016243 0ustar davidpdavidpChanges MANIFEST MANIFEST.SKIP Makefile.PL README lib/Dancer/Plugin/Database.pm t/00-load.t t/01-basic.t t/manifest.t t/pod-coverage.t t/pod.t t/lib/TestApp.pm t/lib/lib/TestHandleClass.pm t/lib/public/.placeholder t/lib/views/.placeholder t/lib/lib/.placeholder META.yml Module YAML meta-data (added by MakeMaker) META.json Module JSON meta-data (added by MakeMaker) Dancer-Plugin-Database-2.09/Makefile.PL0000644000175000017500000000205712255650304017056 0ustar davidpdavidpuse strict; use warnings; use ExtUtils::MakeMaker; WriteMakefile( NAME => 'Dancer::Plugin::Database', AUTHOR => q{David Precious }, VERSION_FROM => 'lib/Dancer/Plugin/Database.pm', ABSTRACT_FROM => 'lib/Dancer/Plugin/Database.pm', ($ExtUtils::MakeMaker::VERSION >= 6.3002 ? ('LICENSE'=> 'perl') : ()), PL_FILES => {}, PREREQ_PM => { 'Test::More' => 0, 'Dancer::Plugin::Database::Core' => '0.04', # Need support for Dancer2-compatible stuff 'Dancer' => 1.3099, }, dist => { COMPRESS => 'gzip -9f', SUFFIX => 'gz', }, clean => { FILES => 'Dancer-Plugin-Database-*' }, META_MERGE => { resources => { repository => 'https://github.com/bigpresh/Dancer-Plugin-Database', bugtracker => 'https://github.com/bigpresh/Dancer-Plugin-Database/issues', homepage => 'https://github.com/bigpresh/Dancer-Plugin-Database/', }, }, ); Dancer-Plugin-Database-2.09/Changes0000644000175000017500000002367712255653306016417 0ustar davidpdavidpRevision history for Dancer-Plugin-Database 2.09 2013-12-22 [ ENHANCEMENTS ] - Tests for cached handle after reconnection 2.08 Sun Sep 1 13:52:52 WEST 2013 [ ENHANCEMENTS ] - Add quick_count method (Thanks to Colin Ewen) 2.07 Tue Jul 30 18:59:30 WEST 2013 - Fix test with wrong base class (part 2) 2.06 Tue Jul 30 18:49:37 WEST 2013 - Fix test with wrong base class. 2.05 2013-07-29 - Remove code from module to share with Dancer2 plugin. - Added dependency on Dancer::Plugin::Database::Core 2.04 2013-03-04 [ ENHANCEMENTS ] - Allow 'sid' to be passed into DSN, for Oracle support. 2.03 2012-12-14 [ BUGFIX ] - Remove left-over debugging warning (thanks to ofosos for reporting) 2.02 2012-12-07 [ ENHANCEMENTS ] - If asked for default connection (no connection name given) but there is no default connection configured, throw a more helpful error message. 2.01 2012-09-18 [ BUGFIX ] - Fix crashing bug when charset: UTF-8 is present - thanks to Hugh Gallagher for reporting & providing fix in RT #79719. Presumably the test suite doesn't set UTF-8, so this failure never showed up in testing :( 2.00 2012-09-17 [ ENHANCEMENTS ] - Support for Dancer 2 - Automatic quoting handles e.g. schema.table properly - GH #33, thanks to mscolly for reporting - Accept limit offset,count syntax too - GH #31, thanks to nicolasfranck for reporting - a value of 0 for connectivity_check_threshold now disables checking entirely - thanks to knutov in GH #22 1.82 2012-06-28 [ BUGFIXES ] - Fix for Debian RT #665221 : http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=665221 - avoid issues if we get a hashref of settings occupying the same region of memory as a previous hashref of settings which since went out of scope but which we still have a handle laying around for. 1.81 2012-03-07 [ BUGFIXES ] - Don't generate invalid SQL with certain uses of where and order_by clauses together (PR-27, thanks to Michael Stapelberg (mstap)) 1.80 2012-02-06 [ ENHANCEMENTS] - New hooks 'database_error', 'database_connect_failed', 'database_connection_lost' - New option 'handle_class' to allow the database handles to be reblessed into an alternative class, allowing you to subclass D::P::D::Handle if you want to extend it All requested by Nick S. Knutov - thanks Nick! 1.70 2012-01-31 [ ENHANCEMENTS ] - New `order_by`, `limit` and `columns` options for quick_select() (Requested by bor in GH-20) 1.60 2011-12-29 [ ENHANCEMENTS ] - Hook support, requested by mdom. Currently supports a database_connected hook position; others may be added in future. Happy New Year! 1.51 2011-11-17 [ BUGFIXES ] - Handle "is" operator properly (particularly if negated) - Issue 15. - Add =encoding utf8 to POD so contributor names render correctly on search.cpan.org / metacpan.org 1.50 2011-10-18 All new features kindly contributed by Mark Allen (@mrallen1) - thanks! - Much more flexible WHERE clauses - e.g. { foo => { like => 'bar'} } - Ability to select only specific columns in quick_select() - New quick_lookup() syntactic sugar method 1.42 2011-08-19 - Don't produce spurious messages about enabling UTF-8 support when we have already done it (PR 9 from James Aitken (LoonyPandora)) 1.41 2011-07-24 - support where clauses with undef values. (Alberto Simões) 1.40 2011-05-29 - Be fork/thread-safe - don't allow processes/threads to share handles. Thanks to Matt S Trout for pointing this out on IRC - cheers mst. - If we're given a pre-assembled DSN, extract the driver from it to avoid a warning, and to allow auto UTF-8 to work. Thanks to Matthew Vickers (mvickers) for bringing this up. 1.30 2011-05-23 - Allow passing an empty hashref for where clause to signify that no where clause is desired (i.e. return all rows). Requested by Carlos Sosa (gnusosa) - thanks! 1.24 2011-05-09 - Bugfixes in logging - avoid DBI swallowing up the param I'd wrongly named, and avoid warnings if any params are undef. Thanks to Martin J Evans (mje) for bringing this up on IRC - thanks for your help Martin. 1.23 2011-04-15 - Only log queries generated by quick_*() helpers in D::P::D::Handle if the log_queries setting was enabled in the configuration. This avoids the potential for the user to be unwittingly logging sensitive information, and would provide a (tiny) performance boost too. 1.22 2011-04-11 - Bugfix: don't needlessly use to_json() in tests, as Dancer doesn't depend on JSON.pm, so tests will fail if it's not available. Reported in RT #66204 by Johnathan (JAWNSY) - thanks! 1.21 2011-03-06 - Bugfix: return undef if connection fails, rather than attempting to re-bless and blowing up. Fixes GH-7, thanks to Nick Hibma 1.20 2011-02-23 - New feature - automatically enable UTF-8 support if the app's charset setting is set to 'UTF-8' and we know how to enable UTF-8 support for the database driver in use. This can be disabled with the new auto_utf8 setting in the plugin's config. - Bugfix - create test DB in memory, not a file named ":memory" by accident. This should fix test failures on Windows, e.g.: http://www.cpantesters.org/cpan/report/d5987aa6-6d07-1014-91a2-7f5be4275be9 1.11 2011-02-18 - Fix bug RT #65825 - quick_select didn't actually use the where clause correctly. - Extended test suite. 1.10 2011-02-11 - New feature quick_select - Fix bug RT #65651, quick_insert generating SQL which MySQL/Postgres didn't accept due to use of quote() rather than quote_identifier(), thanks to Christian Sánchez and Michael Stiller - Fix GH #5 - named connections not working properly - thanks to "crayon" 1.00 2011-01-10 - Bumping to 1.00 to signify being ready for production use, for users who have a mistrust of 0.x version numbers. - Applied Alan Haggai's changes to allow a hashref of settings to be passed to the database() keyword at runtime. Thanks Alan! (This was released as 0.91_01 for testing first.) 0.91 2010-12-21 - Whoah - didn't "use strict" in Dancer::Plugin::Database::Handle! Last tweak release, then I'll push 1.00 out soon. 0.90 2010-12-10 - New features quick_insert, quick_update, quick_delete. The database keyword now returns a Dancer::Plugin::Database::Handle object, which is a subclass of DBI::db so does everything you'd expect a DBI connection handle to do, but adds extra convenience methods. - Fixed test failures on Windows systems. (Large version bump due to new features; assuming there are no reports of issues with this version (there shouldn't be!), I'll release 1.0 soon, for those who look for a >= 1.0 version number as an indication of being production-ready. 0.12 2010-12-03 - Documentation mentioned connectivity-check-threshold instead of the correct connection_check_threshold. Thanks to bessarabov for catching this and submitting corrections via GitHub! 0.11 2010-11-09 (CoD Black Ops day!) - Bugfix: pass connection settings when reconnecting, too. 0.10 2010-10-30 - Add some proper tests [Franck Cuny] 0.09 2010-09-28 - Allow definition of multiple connections, and accept a param to the database() keyword to specify which connection you need a handle for. This was released as 0.08_01 for testing. 0.08 2010-09-14 - Bugfix - make SQLite DWIMmery from previous version actually work. 0.07 2010-09-06 - Extra params in DSN (database, host, port) should be separated with semi-colons, not colons. Thanks to Steve Atkins for reporting this. - Documentation update to reflect use of $dbh->ping - If connecting to SQLite, which requires 'dbname' rather than 'database', provide 'dbname' instead, so it will Just Work 0.06 2010-06-15 - Stupid typo fix in documentation for features added in 0.05. I wish I'd spotted this mistake before releasing 0.05, rather than just after! 0.05 2010-06-15 - Allow parameters to be passed to DBI->connect call (e.g. RaiseError), and support providing a set of statements to execute upon connection. Thanks to Igor Bujna for providing this feature! 0.04 2010-05-20 - If DBD driver does not implement ping(), perform our own connection check by performing a simple query. This will check that the DB connection is still alive, and avoid needless re-connects, which are expensive. Also seems to fix a problem Tadzik saw with a warning from DBD::SQLite when the old handle was thrown away. 0.03 2010-05-17 - Fix warning where $last_connection_check was initially undefined but used in numeric comparison. Thanks to Tadzik for reporting. 0.02 2010-04-18 Documentation fixes, thanks to "mrpants" on Github: - Plugin names in config.yml are case-sensitive for current CPAN releases of Dancer; my commit fdc3f3 makes it case-insenitive, but that hasn't hit CPAN yet, so people using CPAN releases could be confused - stray trailing single-quote in example config 0.01 2010-04-14 Initial version developed.