Use Databases
Last Updated: September 2025
In this recipe you will configure your Tethys installation to use a PostgreSQL database. There are many ways to install PostgreSQL, but for this recipe you will install it using Docker.
Install PostgreSQL database with the PostGIS extension using Docker:
Install Docker Desktop or Docker Engine. Open Docker and have it run in the background while you complete the tutorial.
Open a terminal and run the following command to create a new PostgreSQL with PostGIS Docker container:
docker run -d --name tethys_postgis -e POSTGRES_USER=postgres -e POSTGRES_PASSWORD=mysecretpassword -p 5432:5432 postgis/postgisVerify in Docker desktop that you have a new container running with the name "tethys_postgis" on port
5432(5432:5432).
Add necessary Python dependencies:
To use the PostgreSQL database you need to install the
psycopg2library. Install it using one of the following commands:# conda: conda-forge channel strongly recommended conda install -c conda-forge psycopg2 # pip pip install psycopg2Configure Tethys to use PostgreSQL database:
Stop the Tethys development server if it is running by pressing CTRL-C in the terminal.
Configure the Tethys Portal to use the new Docker database using the
tethys settingscommand:
tethys settings --set DATABASES.default.ENGINE django.db.backends.postgresql --set DATABASES.default.NAME tethys_platform --set DATABASES.default.USER tethys_default --set DATABASES.default.PASSWORD pass --set DATABASES.default.HOST localhost --set DATABASES.default.PORT 5432Run the correct
tethys db configurecommand for your system to prepare the database for use by the Tethys portal:
# Windows System set PGPASSWORD=mysecretpassword tethys db configure # Unix System PGPASSWORD=mysecretpassword tethys db configureThe default password for the
postgis/postgiscontainer is "mysecretpassword". If you changed it, you will need to replace it in the command above.Note
Command line interfaces will not show the keystrokes when entering passwords. Don't worry if you are typing the password into the terminal and nothing shows up on the screen.
Start Tethys the development server (
tethys start) and verify that the app is still working.
Important
You will now need to start the "tethys_postgis" container each time you want to start the Tethys development server. You can do this using the Docker Desktop application or by running the following command:
docker start tethys_postgis