NAME
YAML::DBH
SYNOPSIS
use YAML::DBH 'yaml_dbh';
my $dbh = yaml_dbh( '/home/myself/mysql_credentials.conf' );
DESCRIPTION
Point and shoot method of getting a mysql database handle with only a yaml configuration file as argument.
This is meant for people learning perl who just want to get up and running. It's the simplest customizable way of getting a database handle with very little code.
SUBS
Are not exported by default.
yaml_dbh()
Argument is abs path to yaml config file. Returns DBI mysql dbh handle.
THE YAML CONFIG FILE
You basically need a text file with various parameters. We need the hostname, the username, the password, and the name of your database to connect to. We allow the names of the parameters to be all kinds of silly things like 'user', 'username', 'uname','dbuser', 'DbUsEr' .. Case insensitive. If your config file lacks hostname, we use 'localhost' by default. You can also specify 'driver', by default it is 'mysql'
In /etc/my.conf
---
username: loomis
host: localhost
driver: mysql
database: stuff
password: stuffsee
Also acceptable:
---
DBUSER: loomis
DBHOST: tetranomicon
DBNAME: margaux
DBPASS: jimmy
Also acceptable:
---
user; james
pass: kumquat
dbname: stuff
Also acceptable:
---
username: jack
password: aweg3hmva
database: akira
SEE ALSO
AUTHOR
Leo Charre leocharre at cpan dot org