NAME
IPC::Manager::Base::DBI - Base class for DBI based protocols
DESCRIPTION
This is the base class for DBI based message stores and protocols.
METHODS
See IPC::Manager::Client for inherited methods
DBI SPECIFIC
- $hashref = $con->attrs
-
Get the attributes used for this database connection.
- $dbh = $con->dbh()
- $dbh = $class->dbh(dsn => $dsn, user => $user, pass => $password, attrs => {...})
-
Get the database handle. Can be used on an instance, or on the class with parameters.
- $attrs = $con_or_class->default_attrs()
-
Default attributes to be used for connections when none are specified. Returns undef unless overriden by a subclass.
- $dsn = $con->dsn
-
Get the dsn used for the connection.
- $str = $con->escape
-
Used to escape column names. Each protocol can specify a custom one, for example mysql and sqlite use '`', but postgresql uses '"'.
- $class->init_db(%params)
-
Used during spawn to put the necessary tables into the database if they are not already present.
You may pass
dbh => $dbhto reuse an already-connected DBI handle instead of havinginit_dbopen one from the DSN. - $dbh = $class_or_obj->dbh(dbh => $dbh)
- $dbh = $obj->dbh
- $dbh = $class->dbh(dsn => $dsn, user => $u, pass => $p, attrs => \%a)
-
Get the database handle. When called with a
dbh => $dbhparameter the supplied handle is returned (and cached on an instance) without consulting the DSN. Without that parameter, an instance returns its cached handle if it is still active, otherwise reconnects viaDBI->connectusing the instance's stored DSN / user / pass / attrs. As a class method this unconditionally opens a fresh connection from the supplied parameters. - $route = $class_or_obj->route_from_dbh($dbh)
-
Reassemble a route from a connected DBI handle. The default builds
"dbi:$drv:$name"from$dbh->{Driver}{Name}and$dbh->{Name}. IPC::Manager::Client::SQLite overrides this to return the bare db file path because that is its route format.This is what
ipcm_spawn(dbh =$dbh)> calls to derive the route stored on the resulting Spawn object's info string. See "Spawning against an existing DBI handle" in IPC::Manager. - $password = $con->pass
-
Connection password.
- @sql = $class->table_sql
-
Get the table schema in SQL format to apply to the database.
- $username = $con->user
-
Connection username.
SOURCE
The source code repository for IPC::Manager can be found at https://github.com/exodist/IPC-Manager.
MAINTAINERS
AUTHORS
COPYRIGHT
Copyright Chad Granum <exodist7@gmail.com>.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.