kosmtik / kosmtik

Make maps with OpenStreetMap and Mapnik
Other
721 stars 84 forks source link

Database connect list in UI #255

Open kocio-pl opened 7 years ago

kocio-pl commented 7 years ago

I'd like to have a list of database names to switch in UI. Currently we use gis by default, but I try to render different things, importing data can be very slow and PostgreSQL doesn't provide tools for this (like database name pointer/alias), so I created gis2 database and switch between them with a script:

#!/bin/bash

# Cut any current connections
sudo service postgresql restart
# Make the switch
sudo -u postgres -H -- psql -c "alter database gis rename to temp;"
sudo -u postgres -H -- psql -c "alter database gis2 rename to gis;"
sudo -u postgres -H -- psql -c "alter database temp rename to gis2;"

However:

  1. I have to be careful which database I'm using now to not overwrite something I can't import quickly.
  2. The names are not linked to a database content in any way.
  3. When trying to switch between more databases (city, country, lowzoom continent, temporary...) I would need more scripts like this.

Choosing database connection in Kosmtik would make database switching fast and safe.

pnorman commented 7 years ago

A Mapnik style file can connect to more than one database. It sounds like what you want to do is best covered by a localconfig

kocio-pl commented 7 years ago

Thanks, I will try if it really works for me. However it would be much easier to have a list.

kocio-pl commented 7 years ago

I was shown a multi-location localconfig once, which would be handy:

https://github.com/kosmtik/kosmtik/issues/159#issuecomment-240774850

but it lacks important line about using database source (from dbname[map_id]). How should it look like?