Types::DBI - type constraints for dealing with relational databases
package FroobleBase; use Moose; use Types::DBI; has dbh => ( is => 'ro', isa => Dbh['PostgreSQL'], coerce => 1, required => 1, );
Types::DBI is a type constraint library suitable for use with Moo/Moose attributes, Kavorka sub signatures, and so forth.
This module provides two type constraints, but only Dbh is exported by default.
Dbh
A class type for DBI database handles (DBI::db objects). Coercions from:
Str
The string will be passed to DBI->connect as the DSN. Empty strings will be supplied as the username and password parameters. (Many databases allow the username and password to be specified as part of the DSN. Some databases like SQLite can be usefully used without any authentication details.) The RaiseError attribute will be set to true.
DBI->connect
RaiseError
ArrayRef
The arrayref will be dereferenced and passed to DBI->connect.
Dbh[`a]
Dbh can be parameterized with one or more database names:
isa => Dbh["SQLite"] isa => Dbh[qw/ SQLite PostgreSQL /]
The database names must be a case-sensitive match for the strings returned by $dbh->get_info(SQL_DBMS_NAME).
$dbh->get_info(SQL_DBMS_NAME)
Coercions are inherited from non-parameterized Dbh.
Sth
A class type for DBI statement handles (DBI::st objects). No coercions.
Please report any bugs to http://rt.cpan.org/Dist/Display.html?Queue=Types-DBI.
Types::Standard, DBI.
Toby Inkster <tobyink@cpan.org>.
This software is copyright (c) 2014 by Toby Inkster.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
To install Types::DBI, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Types::DBI
CPAN shell
perl -MCPAN -e shell install Types::DBI
For more information on module installation, please visit the detailed CPAN module installation guide.