NAME
DBIx::QuickORM::DB - Database connection definition for DBIx::QuickORM.
DESCRIPTION
Holds the parameters needed to reach one database: dialect, connection coordinates (DSN or host/port/socket plus user/pass), DBI attributes, and an optional connect callback. It builds DBI handles on demand, either by invoking the callback or by calling DBI->connect with the resolved DSN.
SYNOPSIS
my $db = DBIx::QuickORM::DB->new(
dialect => $dialect,
host => 'localhost',
user => 'someuser',
pass => 'secret',
);
my $dbh = $db->new_dbh;
ATTRIBUTES
- name
-
The name of this database definition.
- connect
-
Optional coderef that returns a new DBI handle. When set it is used instead of building one from the DSN.
- attributes
-
Hashref of DBI connection attributes. Sensible defaults (
RaiseError,PrintError,AutoCommit,AutoInactiveDestroy) are filled in at construction. - db_name
-
The database (schema) name. Falls back to
namewhen not set. - dsn
-
The DBI DSN string. Built from the dialect on first use when not provided.
- host
- port
- socket
-
Connection coordinates. A socket and a host are mutually exclusive.
- user
- pass
-
Credentials passed to
DBI->connect. - created
- compiled
-
Provenance metadata describing where this definition came from.
- dialect
-
The DBIx::QuickORM dialect object (required). Used to build the DSN.
- dbi_driver
-
The DBI driver name associated with this database.
PUBLIC METHODS
- $name = $db->db_name
-
The database name, defaulting to
namewhendb_nameis unset. - $dsn = $db->dsn
-
Returns the DSN, building it from the dialect and caching it on first call.
- $dbh = $db->new_dbh
-
Returns a new DBI handle, using the
connectcallback when present orDBI->connectwith the resolved DSN and credentials otherwise.
SOURCE
The source code repository for DBIx::QuickORM can be found at https://github.com/exodist/DBIx-QuickORM.
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.