PGObject::Util::DBAdmin
PostgreSQL Database Management Facilities for PGObject
PostgreSQL Database Management Facilities for PGObject
Version 0.100.0
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'));
In PostgreSQL, this can refer to the hostname or the absolute path to the directory where the UNIX sockets are set up.
Default '5432'
Creates a new db admin object for manipulating databases.
Exports the database parameters in a hash so it can be used to create another pbject.
Connects to the db using DBI and returns a db connection; allows specification of options in the $options hashref.
returns a version string (like 9.1.4) for PostgreSQL
Returns a list of db names.
Creates a new db. Dies if there is an error.
Supported arguments:
Run the specified file on the db. Accepted parameters are:
Takes a backup and delivers the temporary file name to the handler.
Accepted parameters include:
Returns the file name of the tempfile.
This creates a plain text dump of global (inter-db) objects, such as users and tablespaces. It uses pg_dumpall to do this.
Options include:
Being a plain text file, it can be run using the run_file api.
Restores from a saved file. Must pass in the file name as a named argument.
Recognized arguments are:
Drops the database. This is not recoverable.
Chris Travers, "<chris at efficito.com>"
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.
You can find documentation for this module with the perldoc command.
perldoc PGObject::Util::DBAdmin
You can also look for information at:
<http://rt.cpan.org/NoAuth/Bugs.html?Dist=PGObject-Util-DBAdmin>
<http://annocpan.org/dist/PGObject-Util-DBAdmin>
<http://cpanratings.perl.org/d/PGObject-Util-DBAdmin>
<http://search.cpan.org/dist/PGObject-Util-DBAdmin/>
Copyright 2014-2016 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.