Tutorial: using postgres database

You can use a postgres database for PyWPS, the default is sqlite. PyWPS is using SQLAlchemy, see the PYWPS documentation for details.

First run the Emu default installation:

$ git clone https://github.com/bird-house/emu.git
$ cd emu
$ make clean install

The default installation is using sqlite. We now need a postgres database. If you don’t have one yet you can use a postgres docker container.

$ docker pull postgres
$ docker run --name postgres -e POSTGRES_PASSWORD=postgres -p 5432:5432 -d postgres

The postgres database is now available on default port 5432.

SQLAlchemy needs the psycopg2 postgres adapter. This was installed by the Emu installation process. You can also install it manually via conda:

$ conda install psycopg2

The SQLAlchemy connection string for this database is:

# postgresql+psycopg2://user:password@host:port/dbname
postgresql+psycopg2://postgres:postgres@localhost:5432/postgres

Configure this connection string in custom.cfg, pywps section, database option:

$ vim custom.cfg
[settings]
hostname = localhost
# http-port = 8094
# output-port = 8090

[pywps]
database = postgresql+psycopg2://postgres:postgres@localhost:5432/postgres

Update the pywps configuration:

$ make update

Check the updated pywps configuration (optional):

$ less $HOME/birdhouse/etc/pywps/emu.cfg
[logging]
database=postgresql+psycopg2://postgres:postgres@localhost:5432/postgres

Start the emu service:

$ make restart

Your Emu WPS service should be available at the following URL:

$ firefox http://localhost:8094/wps?request=GetCapabilities&service=WPS