NAME
PGObject::Util::DBAdmin - PostgreSQL Database Management Facilities for PGObject
VERSION
Version 0.03
SYNOPSIS
This module provides an interface to the basic Postgres db manipulation utilities.
my $db = PGObject::Util::DBAdmin->new(
username => 'postgres',
password => 'mypassword',
host => 'localhost',
port => '5432',
dbname => 'mydb'
);
my @dbnames = $db->list_dbs(); # like psql -l
$db->create(); # createdb
$db->run_file(file => 'sql/initial_schema.sql'); # psql -f
my $filename = $db->backup(format => 'c'); # pg_dump -Fc
my $db2 = PGObject::Util::DBAdmin->new($db->export, (dbname => 'otherdb'));
PROPERTIES
username
password
host
In PostgreSQL, this can refer to the hostname or the absolute path to the directory where the UNIX sockets are set up.
port
Default '5432'
dbname
SUBROUTINES/METHODS
new
Creates a new db admin object for manipulating databases.
export
Exports the database parameters in a hash so it can be used to create another pbject.
connect
Connects to the db using DBI and returns a db connection
list_dbs
Returns a list of db names.
create
Creates a new db. Dies if there is an error.
Supported arguments:
- copy_of
-
Creates the db as a copy of the one of that name. Default is unspecified.
run_file
Run the specified file on the db. Accepted parameters are:
- file
-
Path to file to be run
- log
-
Path to combined stderr/stdout log. If specified, do not specify other logs as this is unsupported.
- errlog
-
Path to error log to store stderr output
- stdout_log
-
Path to where to log standard outut
- continue_on_error
-
If set, does not die on error.
backup
Takes a backup and delivers the temporary file name to the handler.
Accepted parameters include:
- format
-
The specified format, for example c for custom. Defaults to plain text
- tempdir
-
The directory to store temp files in. Defaults to $ENV{TEMP} if set and '/tmp/' if not.
Returns the file name of the tempfile.
restore
Restores from a saved file. Must pass in the file name as a named argument.
Recognized arguments are:
- file
-
Path to file
- format
-
The specified format, for example c for custom. Defaults to plain text
- log
-
Path to combined stderr/stdout log. If specified, do not specify other logs as this is unsupported.
- errlog
-
Path to error log to store stderr output
- stdout_log
-
Path to where to log standard outut
drop
Drops the database. This is not recoverable.
AUTHOR
Chris Travers, <chris at efficito.com>
BUGS
Please report any bugs or feature requests to bug-pgobject-util-dbadmin at rt.cpan.org
, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=PGObject-Util-DBAdmin. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.
SUPPORT
You can find documentation for this module with the perldoc command.
perldoc PGObject::Util::DBAdmin
You can also look for information at:
RT: CPAN's request tracker (report bugs here)
http://rt.cpan.org/NoAuth/Bugs.html?Dist=PGObject-Util-DBAdmin
AnnoCPAN: Annotated CPAN documentation
CPAN Ratings
Search CPAN
ACKNOWLEDGEMENTS
LICENSE AND COPYRIGHT
Copyright 2014 Chris Travers.
This program is distributed under the (Revised) BSD License: http://www.opensource.org/licenses/BSD-3-Clause
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
* Neither the name of Chris Travers's Organization nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.