Skip to content

pgcli

The Pgcli resource reference. This resource installs [pgcli] (https://www.pgcli.com) a command line REPL to manipulate postgres databases.

Parameters:

No parameters are currently available for the pgcli install

Example usage:

codify.json
[
{
"type": "pgcli"
}
]

Dependencies

This resource has a dependency on homebrew. A working version of homebrew must be installed in order for this resource to work. See the homebrew resource to see how to install it using Codify. The dependency between the two resources will be automatically resolved and homebrew will be installed first if both are specified in a config.

The pgcli tool also has a dependency on postgres. The pgcli resources uses homebrew underneath and will automatically install postgres if it’s not installed.

Setting up a local Postgres DB

  1. Create a codify.json file anywhere.
  2. Open codify.json with your file editor and paste in the follow configs.
codify.json
[
{
"type": "homebrew",
"formulae": [
"postgresql@14"
]
},
{ "type": "pgcli" }
]
  1. Run codify apply in the directory of the file. And it should install postgres and pgcli to your system
codify.json
codify apply
  1. Open a new terminal window and start the database server with this command
codify.json
brew services start postgresql
  1. Create a new database. Replace mydb with your desired name
codify.json
createdb mydb
  1. Connect to the database using pgcli and you’re done!
codify.json
pgcli mydb
  1. Once you’re done using postgres, stop the service.
codify.json
brew services stop postgresql