Browse Source

* refactor database connection options

master
Alex 'AdUser' Z 7 years ago
parent
commit
e6c8dec454
  1. 6
      docs/cmtd.conf.sample
  2. 5
      lib/CMTD.pm

6
docs/cmtd.conf.sample

@ -1,6 +1,10 @@
{ {
secret => 'cookie-sign-key', secret => 'cookie-sign-key',
db => ['dbi:SQLite:dbname=data/data.db'], db => {
dsn => 'dbi:SQLite:dbname=data/data.db',
user => undef,
pass => undef,
},
captcha => { captcha => {
tries => 5, tries => 5,
limit => 500, limit => 500,

5
lib/CMTD.pm

@ -25,9 +25,10 @@ sub startup {
return $cap; return $cap;
}); });
$self->app->attr(db => sub { $self->app->attr(db => sub {
my $config = $self->app->config->{db} || []; my $c = $self->app->config->{db} || {};
require DBIx::Simple; require DBIx::Simple;
my $dbh = DBIx::Simple->new(@{ $config }); my %opts = (AutoCommit => 1, RaiseError => 1, sqlite_see_if_its_a_number => 1);
my $dbh = DBIx::Simple->new($c->{dsn}, $c->{user}, $c->{pass}, \%opts);
return $dbh; return $dbh;
}); });

Loading…
Cancel
Save