View on
MetaCPAN is shutting down
For details read Perl NOC. After June 25th this page will redirect to
Dave Rolsky > Pg-CLI > Pg::CLI::psql



Annotate this POD


View/Report Bugs
Module Version: 0.13   Source  


Pg::CLI::psql - Wrapper for the psql utility


version 0.13


  my $psql = Pg::CLI::psql->new(
      username => 'foo',
      password => 'bar',
      host     => '',
      port     => 5433,

      database => 'database',
      options  => [ '-c', 'DELETE FROM table' ],

      database => 'database',
      file     => 'thing.sql',

  my $sql = '...';
  my $errors;
      database => 'foo',
      stdin    => \$sql,
      stderr   => \$errors,


This class provides a wrapper for the psql utility.


This class provides the following methods:

Pg::CLI::psql->new( ... )

The constructor accepts a number of parameters:

$psql->run( database => ..., options => [ ... ] )

This method runs a command against the specified database. You must pass one or more options that indicate what psql should do.

This method also accepts optional stdin, stdout, and stderr parameters. These parameters can be any defined value that could be passed as the relevant parameter to IPC::Run3's run3 subroutine.

Most notably, you can pass scalar references to pipe data in via the stdin parameter or capture output sent to stdout or stderr

$psql->execute_file( database => ..., file => ... )

This method executes the specified file or files against the database. file should either be the path to a single file as a string or Path::Class::File or an arrayref of such paths. You can also pass additional options via the options parameter.

This method also accepts optional stdin, stdout, and stderr parameters, just like the $psql->run() method.


Returns a the three part version as a string.


Returns the first two decimal numbers in the version.


Bugs may be submitted at or via email to

I am also usually active on IRC as 'autarch' on irc://


The source code repository for Pg-CLI can be found at


Dave Rolsky <>


This software is Copyright (c) 2018 by Dave Rolsky.

This is free software, licensed under:

  The Artistic License 2.0 (GPL Compatible)

The full text of the license can be found in the LICENSE file included with this distribution.

syntax highlighting: