We're setting up Redash and need to connect to multiple Data Sources that are Postgres databases that require SSL connections. I have a postgres.key
and postgres.crt
file from each database. Redash is running as user redash
on Ubuntu 16.04.
What should I do with these keys so that Redash (and the Python psycopg2
library, behind the scenes) can find the proper credentials to connect to the Data Sources?
The best I've been able to do is put one set of them in /home/redash/.postgresql
, which is where psycopg2
looks for credentials by default. However, that doesn't allow me to connect to the second database.
Best Answer
use the
sslcert
andsslkey
paramterer in the connection string to indicate the files you want.https://www.postgresql.org/docs/10/static/libpq-connect.html#LIBPQ-PARAMKEYWORDS
eg:
probably something using string::format would be more practical.
.
If that seems too messy
Using a service definition to store the parameters is another option define the connection paramaters (like above) for each server in
pg_services.conf
(create that file) and use connection strings likehttps://www.postgresql.org/docs/10/static/libpq-pgservice.html
other clients (like psql) can also use the services thus defined, so this way will save you typing in the future.
but it seems redash is configured using environment variables with the database as as a URL perhaps like this:
like this with a service definition
or
like this explicitly:
from a bries sfan of the docs redash seems to use
postgres
for db_user and db_nameso far as I know libpq does not use a different interface for database names, connection strings, and database urls, where one can be used any other form can be used instead, however the redash docs say to use a URL.
https://www.postgresql.org/docs/10/static/libpq-connect.html#LIBPQ-CONNSTRING