Codify

pgcli

A reference page for the pgcli resource

The Pgcli resource reference. This resource installs pgcli a command line REPL to manipulate postgres databases.

Parameters:

No parameters are currently available for the pgcli install

Example usage:

codify.jsonc
[
  {
    "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

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

On this page