Skip to main content

You Can Install PostgreSQL with conda?

ยท 2 min read
Travis Hathaway
Conda maintainer ๐Ÿ‘ท๐Ÿ”ง
Banner image for You Can Install PostgreSQL with conda? blog post

Conda has long been the driver of data science workflows because of its unique ability to manage the complexities around Python packaging's diverse dependency requirements. It's precisely because of this that conda is also able to handle managing much more than Python dependencies.

In the first part of a multi-part blog post series, we'll show the strengths of conda's flexibility and provide a tutorial on how you can install PostgreSQL for local development environments.

Prerequisitesโ€‹

Throughout this tutorial, we show you how to install and run PostgreSQL from conda-forge using either conda or pixi. Please refer to those project's documentation for information on how install them.

Setting up your environmentโ€‹

To start, we'll create a new environment with all the required dependencies for install PostgreSQL. We'll also add a couple of PostgreSQL extensions: PostGIS and PGRouting.

To create a new conda environment with PostgreSQL GIS extensions, run the following command:

conda create \
--name postgresql \
--channel conda-forge \
postgresql

Running PostgreSQLโ€‹

Now that we have our environment setup and packages installed, we can initialize our database and get it running. The postgresql package exposes the following commands that we'll use to do that:

  • initdb
  • createuser
  • createdb
  • pg_ctl

TODOโ€‹

Remaining items to include in the blog post:

  • Running initdb
  • Starting and stopping the server
  • Making edits to the server configuration
  • Notes of security