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


version 0.14


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

      database => 'NewDB',


This class provides a wrapper for the dropdb utility.


This class provides the following methods:

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

The constructor accepts a number of parameters:

  • executable

    The path to dropdb. By default, this will look for dropdb in your path and throw an error if it cannot be found.

  • username

    The username to use when connecting to the database. Optional.

  • password

    The password to use when connecting to the database. Optional.

  • host

    The host to use when connecting to the database. Optional.

  • port

    The port to use when connecting to the database. Optional.

  • require_ssl

    If this is true, then the PGSSLMODE environment variable will be set to "require" when connecting to the database.

$dropdb->run( database => $db, ... )

This method runs the dropdb command with the given options.

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

This method accepts the following arguments:

  • database

    The name of the database to drop. Required.

  • options

    A list of additional options to pass to the command. Optional.


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.