-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Additionally, provides the convenience method 'connect_from_config' which enables pulling credentials from a config file.
- Loading branch information
0 parents
commit 3cc978a
Showing
1 changed file
with
36 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |