Install

Compatibility:

Tested on macOS and Linux. Runs on Python 3.6+.

I have not personally tested this on Windows, but all the underlying libraries used by this project are cross-platform compatible including Windows. If you have a Windows machine, I'd very much appreciate if you could test it out and let me know. I do want to support Windows, I just don't have the resources right now.

Quick start:

If you already know how to install python packages, then you can do:

$ pip install pgcli

or

$ easy_install pgcli

You might need sudo.

Detailed:

macOS:

The easiest way install pgcli on an macOS machine is to use Homebrew. Please be aware that this will install postgresql if it's not already installed.

$ brew install pgcli

That's it. You can now launch it by typing pgcli on the command line.

Alternatively, since pgcli is a python package you can install it via the python package manager pip. There is also an older package manager known as easy_install but it is replaced by pip.

Check if pip is installed on the system.

$ which pip

If the above command returns an error, then you do not have pip installed on your computer.

Most macOS systems comes pre-installed with python and easy_install. You can use easy_install to install pip.

$ sudo easy_install pip

pgcli uses psycopg to talk to postgres database. In order to install psycopg, you will need libpq installed on your system. The easiest way to get the necessary libraries, is to install postgresql on your system.

$ brew install postgresql

You will also need C compiler installed on your system in order to compile the required files for psycopg. Install XCode from AppStore and then install the CommandLineTools which will install gcc or an equivalent C compiler on your system. I typically do the following:

$ xcode-select --install   # This will install the command line tools for xcode.

Now that the required dependencies are satisfied you are ready to install pgcli.

$ sudo pip install pgcli

Linux:

The recommended way to install Python packages is to use a package manager called called pip. There is also an older package manager known as easy_install but it is replaced by pip.

Check if pip is installed on the system.

$ which pip

If the above command returns an error, then you do not have pip installed on your computer. You can install it using your OS package manager.

Debian based systems (Debian, Ubuntu, Mint etc)

$ sudo apt-get install python-pip

For Redhat based systems (Fedora, Centos, RHEL etc)

$ sudo yum install python-pip

Pgcli uses psycopg to talk to postgres database. In order to install psycopg, you will need libpq and python-dev installed on your system. Since psycopg is a C extension for Python, a C compiler is needed to install it on your system.

$ sudo apt-get install libpq-dev python-dev   # debian

or

$ sudo yum install postgresql-devel python-devel  # redhat

Now that the required dependencies are satisfied you are ready to install pgcli.

$ sudo pip install pgcli

What about psycopg2-binary:

Psycopg2 maintainers do not recommend using binary package version for production, this is why pgcli specifies the source package (psycopg2) as dependency, vs psycopg2-binary:

http://initd.org/psycopg/docs/install.html#binary-install-from-pypi

However, this workaround may help if you're unable to build the source psycopg2 package:

$ pip install pgcli --only-binary psycopg2

If you're still having trouble getting pgcli installed, please feel free to contact me.

blogroll

social