Project-Easy

 view release on metacpan or  search on metacpan

lib/Project/Easy/Helper.pm  view on Meta::CPAN

use Class::Easy;

use base qw(DBI::Easy::{$dbi_easy_scope});

our $wrapper = 1;

sub _init_db {
	my $self = shift;
	
	$self->dbh ($::project->can ('db_{$datasource}'));
}

1;

########################################
# IO::Easy::File template
########################################

########################################
# IO::Easy::File config-usage
########################################

Usage:  db.<database_id> template db.<template_name>	OR
		db.<database_id>.username set "<password>"	  OR
		db.<database_id>.username

Example (add new database config "local_test_db_id" with mysql template) :
bin/config db.local_test_db_id template db.mysql

########################################
# IO::Easy::File template-db.sqlite
########################################

{
	"driver_name": "SQLite",
	"attributes": {
		"dbname" : null
	},
	"options": {
		"RaiseError": 1,
		"AutoCommit": 1,
		"ShowErrorStatement": 1
	}
}


########################################
# IO::Easy::File template-db.mysql
########################################

{
	"user": null,
	"pass": null,
	"driver_name": "mysql",
	"attributes": {
		"database" : null,
		"mysql_multi_statements": 0,
		"mysql_enable_utf8": 1,
		"mysql_auto_reconnect": 1,
		"mysql_read_default_group": "perl",
		"mysql_read_default_file": "{$root}/etc/my.cnf"
	},
	"options": {
		"RaiseError": 1,
		"AutoCommit": 1,
		"ShowErrorStatement": 1
	}
}

########################################
# IO::Easy::File template-db.oracle
########################################

{
	"user": null,
	"pass": null,
	"driver_name": "oracle",
	"options" : {
		"AutoCommit" : 1,
		"ShowErrorStatement" : 0,
		"RaiseError" : 1,
		"PrintError" : 0,
		"LongReadLen" : 1024288,
		"LongTruncOk" : 1,
		"ora_charset" : "AL32UTF8"
	},
	"do_after_connect" : [
		"alter session set nls_date_format='yyyy-mm-dd hh24:mi:ss'"
	]
}

########################################
# IO::Easy::File template-db.default
########################################
{
	"user": null,
	"pass": null,
	"driver_name": null, // mysql, oracle, pg, …
	"attributes": {
		"database" : null
	},
	"options": {
		"RaiseError": 1,
		"AutoCommit": 1,
		"ShowErrorStatement": 1
	}
}



( run in 1.110 second using v1.01-cache-2.11-cpan-39bf76dae61 )