NAME

XAS::Model::Schema - A class for the XAS environment

SYNOPSIS

use XAS::Model::Schema;
use XAS::Mode::Database;

XAS::Model::Database->schema('XAS::Model::Database::Testing');
my $schema = XAS::Model::Schema->opendb('testing');

DESCRIPTION

This module loads database connection information from a file. This file may be located in the users home directory or in the XAS config directory. With the usual convention of the user specific file will override the global generic file. This file is named database.ini.

Format of the configuration file is as follows:

[progress]             - corresponds to what is given to opendb()
dbname = monitor       - name of the database
dsn = SQLite           - corresponds to the dbd driver
user = username        - the user context to use
password = password    - the password for that context

When using ODBC with a user level DSN or a dynamic connection, you should add the following items:

driver = SQL Server
server = localhost,1234 - (host,port)

When using PostgresSQL (Pg), you can add the following items:

port = 5432
host = localhost
sslmode = something
options = something

Or a service name, which is not compatible with the above.

service = service name

There can be multiple stanzas, the first one that matches is used.

METHODS

opendb($database)

This method makes the connection to the database. It takes these parameters:

$database

The name of the database. This is defined in the database.ini file.

dbix_exceptions($error)

This method converts the internal DBIx::Class exceptions into a XAS exception. It takes these parameters:

$error

The error string supplied by DBIx::Class

filter_loaded_credentials($class, $config, $connect_args)

This method is an override for the one provided by DBIx::Class::Schema::Config. It sets various defaults to be used when connecting to certain databases. There are defaults for SQLite, PostgreSQL and ODBC connections. The following parameters are supplied from DBIx::Class::Schema::Config.

$class
$config
$connecti_args

SEE ALSO

XAS::Model
XAS
DBIx::Class::Schema::Config

AUTHOR

Kevin L. Esteb, <kevin@kesteb.us>

COPYRIGHT AND LICENSE

Copyright (c) 2012-2015 Kevin L. Esteb

This is free software; you can redistribute it and/or modify it under the terms of the Artistic License 2.0. For details, see the full text of the license at http://www.perlfoundation.org/artistic_license_2_0.