Skip to content

Commit

Permalink
Adds DBIx::Class::Schema CpanStats
Browse files Browse the repository at this point in the history
Additionally, provides the convenience method 'connect_from_config'
which enables pulling credentials from a config file.
  • Loading branch information
ureesoriano committed Aug 17, 2016
0 parents commit 3cc978a
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions CpanStats.pm
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
use utf8;
package CpanStats;
# ABSTRACT: DBIx::Class::Schema for CPANTesters cpanstats db

use strict;
use warnings;

use base 'DBIx::Class::Schema';

__PACKAGE__->load_namespaces;


our $VERSION = 0; # DBIx::Class::Deploymenthandler?



# Convenience connect method
sub connect_from_config {
my $schema = shift->connect(
"DBI:mysql:mysql_read_default_file=$ENV{HOME}/.cpanstats.cnf;".
"mysql_read_default_group=application;mysql_enable_utf8=1",
undef, # user
undef, # pass
{
AutoCommit => 1,
RaiseError => 1,
mysql_enable_utf8 => 1,
quote_char => '`',
name_sep => '.',
},
);
$schema->txn_begin;
return $schema;
}

1;

0 comments on commit 3cc978a

Please sign in to comment.