endlessm / azafea

Service to track device activations and usage metrics
Mozilla Public License 2.0
10 stars 2 forks source link

config: Allow passing PostgreSQL connection arguments #78

Closed bochecha closed 4 years ago

bochecha commented 4 years ago

PostgreSQL's libpq supports many connection arguments:

https://www.postgresql.org/docs/current/libpq-connect.html#LIBPQ-PARAMKEYWORDS

SQLAlchemy makes it easy to pass them down to PsycoPG2 and libpq:

https://docs.sqlalchemy.org/en/13/core/engines.html#custom-dbapi-args

This commit introduces a new "connect_args" configuration table, nested under the "postgresql" one.

It can be passed arbitrary key/values, like "sslmode" or "connect_timeout" for example.

Fixes #74

bochecha commented 4 years ago

@adarnimrod with this, you'll be able to do the following in the configuration file:

[postgresql.connect_args]
sslmode = "require"
sslcert = "/path/to/cert"
connect_timeout = 3
adarnimrod commented 4 years ago

Thanks. That's exactly what I wanted.