DBIx::PgLink::Adapter - DBI wrapper for DBIx::PgLink suite
use DBIx::PgLink::Adapter; $db = DBIx::PgLink::Adapter->new(); $db->install_roles(qw/NestedTransaction TraceDBI/); $db->install_roles('Reconnect'); $db->reconnect_retries(10); $db->connect("dbi:Pg:host=127.0.0.1;db=postgres", "postgres", "", { RaiseError=>1, AutoCommit=>1 }); $db->do("SET client_min_messages=INFO"); $db->dbh->{'pg_enable_utf8'} = 1; $st = $db->prepare("SELECT * FROM pg_database"); $st->execute; @row = $st->fetchrow_array;
See also DBIx::PgLink
Class wraps DBI database handle and provides base for further extending.
Used Moose object system.
Extending can be made by subclassing for specific data source type and/or by adding roles.
Subclasses of DBIx::PgLink::Adapter may implement missing or broken functionality of DBD driver or underlying driver/database.
DBIx::PgLink::Adapter
Roles (a.k.a. traits or mixins) supply additional functionality and may be composed in any combinations (in theory). Adapter can load role: 1) in compile-time via with clause 2) in run-time via install_role subroutine or via direct meta-class manipulation.
with
install_role
Descendant adapter classes and extra roles can have any name.
Default constructor.
Connect to DBI datasource. Returns database handle.
install_roles
Apply roles to current object. Role name can be full package name or just last portion, which defaults to 'DBIx::PgLink::Roles::' namespace.
Methods of DBI database handle. Can be overrided and extended.
All methods that should return statement handle returns instance of <DBIx::PgLink::Adapter::st> class instead.
is_transaction_active
Utility function. Return true if connection is in transaction.
format_routine_call
$sql = $adapter->format_routine_call($catalog, $schema, $routine, $returns_set, \@args);
Generate SQL query for routine call.
$returns_set is boolean, pass true if routine returns set.
$returns_set
\@args is array of hashes for routine arguments. For database that supports named arguments each entry must contains 'arg_name' value.
\@args
Generic implementation use 'SELECT' keyword with positional call syntax (PostgreSQL-compatible).
NOTE: DBI attributes are not imported. Use dbh attribute for direct access.
dbh
Weak reference to optional parent of DBIx::PgLink::Connector class. Read only.
Wrapped DBI database handle.
Statement object created by prepare database method.
prepare
Methods of DBI statement handle. Can be overrided and extended.
Link to Adapter instance. Read only.
Wrapped DBI statement handle. Read only.
I need this features:
1) Cross-database support 2) Easy extending 3) Mixin/trait-like composing of functionality in run time 4) Set of ready pluggable modules. Particular interest in disconnection handling.
+ Good cross-database support - Too ORM-ish. Overkill for data access from one relational engine to another RDBMS.
+ Good set of predifined roles - No cross-database support
Class construction is really SLOW. It is a price for extensibility. See Moose::Cookbook::WTF.
DBI, DBIx::PgLink Moose
Alexey Sharafutdinov <alexey.s.v.br@gmail.com>
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.8 or, at your option, any later version of Perl 5 you may have available.
To install DBIx::PgLink, copy and paste the appropriate command in to your terminal.
cpanm
cpanm DBIx::PgLink
CPAN shell
perl -MCPAN -e shell install DBIx::PgLink
For more information on module installation, please visit the detailed CPAN module installation guide.