Pg::CLI::psql - Wrapper for the psql utility
my $psql = Pg::CLI::psql->new( username => 'foo', password => 'bar', host => 'pg.example.com', port => 5433, ); $psql->run( database => 'database', options => [ '-c', 'DELETE FROM table' ], ); $psql->execute_file( database => 'database', file => 'thing.sql', );
This class provides a wrapper for the psql utility.
This class provides the following methods:
The constructor accepts a number of parameters:
The path to psql. By default, this will look for psql in your path and throw an error if it cannot be found.
The username to use when connecting to the database. Optional.
The password to use when connecting to the database. Optional.
The host to use when connecting to the database. Optional.
The port to use when connecting to the database. Optional.
If this is true, then the
PGSSLMODE environment variable will be set to "require" when connecting to the database.
This defaults to true. When true, the "-q" flag is passed to psql whenever it is executed.
This method runs a command against the specified database. You must pass one or more options that indicate what psql should do.
This method executes the specified file against the database. You can also pass additional options via the
Returns a the three part version as a string.
Returns the first two decimal numbers in the version.
See Pg::CLI for bug reporting details.
Dave Rolsky <email@example.com>
This software is Copyright (c) 2010 by Dave Rolsky.
This is free software, licensed under:
The Artistic License 2.0