The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

ZConf::DBI - Stores DBI connection information in ZConf.

VERSION

Version 0.1.0

SYNOPSIS

    use ZConf::DBI;
    use DBI::Shell;

    my $foo=ZConf::DBI->new;

    my $ds=$foo->getDS('tigerline');
    my $user=$foo->getDSuser('tigerline');
    my $pass=$foo->getDSpass('tigerline');

    DBI::Shell->new($ds, $user, $pass)->run;

METHODS

new

This initiates the object.

hash values

zconf

If this is defined, it will be used instead of creating a new ZConf object.

addDS

This adds a new data source.

args hash

The only required is 'ds'. Any thing else can be undef.

attr

This hash reference contains any attributes one wishes to pass to the new connections.

ds

This is the data source string.

name

The name of the new data source.

pass

This is the password to use.

This can be undefined.

user

This is the the user to use.

This can be undefined.

    $foo->addDS({ds=>$datasource, user=>$user, pass=>$pass, name=>'some name'  });
    if($foo->error){
        print "Error!\n";
    }

connect

This connects and returns the database handle formed by DBI->connect.

This just returns the database handle and does not check if succedded or not.

Only one arguement is required and it is the name of the data source.

    my $dbh=$foo->connect('someDS');
    if($foo->error){
        print "Error!\n";
    }

dataSourceExists

This checks if the specified data source exists or not.

Only one arguement is taken and it is the name of data source to check for.

The returned value is either a Perl boolean value.

    if(!$foo->dataSourceExists('bar')){
        print "The data source 'bar' does not exist\n";
    }

delDS

This removes a data source.

delSet

This removes the specified ZConf set.

    $foo->delSet('someSet');
    if($foo->error){
        print "Error!\n";
    }

getDS

This gets the data source value for a data source.

Only one arguement is required and is the name of the data source.

    my $ds=$foo->getDS("someDS");
    if($foo->{error}){
        print "Error!\n";
    }

getDSattrs

This gets the pass for a data source.

This can potentially be undef.

Only one arguement is required and is the name of the data source.

    my %attrs=$foo->getDS("someDS");
    if($foo->error){
        print "Error!\n";
    }

getDSpass

This gets the pass for a data source.

This can potentially be undef.

Only one arguement is required and is the name of the data source.

    my $ds=$foo->getDS("someDS");
    if($foo->error){
        print "Error!\n";
    }

getDSuser

This gets the user for a data source.

This can potentially be undef.

Only one arguement is required and is the name of the data source.

    my $ds=$foo->getDS("someDS");
    if($foo->error){
        print "Error!\n";
    }

init

This initiates a new set. If a set already exists, it will be overwritten.

If the set specified is undefined, the default will be used.

The set is not automatically read.

    $foo->init($set);
    if($foo->error){
        print "Error!\n";
    }

listDSs

This lists the available data sources.

No arguements are taken.

The returned value is a array of available data sources.

    my @datasources=$foo->listDSs;
    if($foo->error){
        print "Error!\n";
    }else{
        use Data::Dumper;
        print Dumper(\@daasources);
    }

listSets

This lists the available sets for the ZConf config.

    my @sets=$foo->listSets;
    if($foo->error){
        print "Error!\n";
    }

readSet

This reads a specified ZConf set.

If no set is specified, the default is used.

    $foo->readSet('someSet');
    if($foo->error){
        print "Error!\n";
    }

setDS

This changes the data source value for a already setup data source.

Two arguements are required. The first is the data source name and the second is the data source.

    $foo->setDS('someDS', 'DBI:mysql:databasename');
    if($foo->error){
        print "Error!\n";
    }

setDSattr

This changes the data source value for a already setup data source.

Three arguements are required. The first is the data source name, second is the data source, and the third is the value.

If the value is undefined, the attribute is removed.

    $foo->setDS('someDS', 'someAttr', 'someValue');
    if($foo->error){
        print "Error!\n";
    }

setDSpass

This changes the password value for a already setup data source.

Two arguements are required. The first is the data source name and the second is the password.

    $foo->setDS('someDS', 'somePass');
    if($foo->error){
        print "Error!\n";
    }

setDSuser

This changes the user value for a already setup data source.

Two arguements are required. The first is the data source name and the second is the user.

    $foo->setDS('someDS', 'someUser');
    if($foo->error){
        print "Error!\n";
    }

ERROR CODES/HANDLING

Error handling is provided by Error::Helper. The error codes are as below.

1

ZConf errored.

2

Data source name not specified.

3

Data source not defined.

4

The data source already exists.

5

The data source name contains a '/'.

6

The data source does not exist.

7

Data source does not exist.

8

No attribute specified.

9

No value specified.

10

No user specified.

11

No password specified.

ZCONF KEYS

datasources/<data source name>/ds

This is the data source string for a data source.

This is required.

datasources/<data source name>/user

This is the user for a data source.

This may not be defined.

datasources/<data source name>/pass

This is the password for a data source.

This may not be defined.

datasources/<data source name>/attr/<attribute name>

This contains any attributes for a data source.

AUTHOR

Zane C. Bowers-Hadley, <vvelox at vvelox.net>

BUGS

Please report any bugs or feature requests to bug-zconf-devtemplate at rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=ZConf-DBI. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.

SUPPORT

You can find documentation for this module with the perldoc command.

    perldoc ZConf::DBI

You can also look for information at:

ACKNOWLEDGEMENTS

COPYRIGHT & LICENSE

Copyright 2012 Zane C. Bowers-Hadley, all rights reserved.

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.