NAME
DBIx::PgLink - external database access from PostgreSQL backend using Perl DBI
SYNOPSIS
For SQL script examples see DBIx::PgLink::Manual::Usage.
In PL/PerlU function
use DBIx::PgLink;
$conn = DBIx::PgLink->connect('NORTHWIND');
$db = $conn->adapter;
$db->begin_work;
$st = $db->prepare('SELECT * FROM Orders WHERE OrderID=?');
$st->execute(42);
while (@row = $st->fetchrow_array) {
...
}
$db->commit;
$conn->builder->build_accessors(
local_schema => 'northwind',
remote_schema => 'dbo',
remote_object => 'Order%',
);
DBIx::PgLink->disconnect('NORTHWIND');
DESCRIPTION
PgLink is based on DBI-Link project for accessing external data sources from PostgreSQL backend.
This module can be used only in untrusted PL/Perl function.
Differences from DBI-Link
PgLink is standard Perl module
While DBI-Link store all Perl code in PL/Perl functions, DBIx-PgLink use Perl infrastructure for installation and testing.
Extensibility
The main goal is to compose functionality without writing a line of Perl code.
Flexible data type mapping
Customizable SQL queries.
Parametrized queries
Prevent SQL-injection attack.
Mapping between database accounts
Can connect with different credentials for each PostgreSQL user.
Additional functionality for DBI
Such as automatic reconnection after network outage, nested transactions, charset conversion, prepared statement cache management.
SUBROUTINES
- connect
-
$adapter = connect($conn_name);
Load connection metadata from PostgreSQL and connect to remote datasource.
Returns instance of DBIx::PgLink::Connector object.
Subsequent calls return the same cached object. Single connection persists while PostgreSQL session live or until explicit
disconnect
. - disconnect
-
disconnect($conn_name);
Close connection to remote database and delete entry from cache.
- named_params
-
my $hashref = named_params(\@_, qw/foo bar/); # { foo=>$_[0], bar=>$_[1] }
Utility subroutine. Converts positional arguments of PL/Perl function (passed in @_) to named parameters. NULL arguments are ignored.
Exported by default.
SEE ALSO
DBIx::PgLink::Manual::Install, DBIx::PgLink::Manual::Usage, DBI, DBIx::PgLink::Connector, DBIx::PgLink::Adapter, DBIx::PgLink::Accessor::Table, DBIx::PgLink::Local, http://pgfoundry.org/projects/dbi-link/
AUTHOR
Alexey Sharafutdinov <alexey.s.v.br@gmail.com>
COPYRIGHT AND LICENSE
Copyright (C) 2007 by Alexey Sharafutdinov
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.
DBI-Link project by David Fetter under BSD License.