endlessm / azafea

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

Add database connection parameters configuration option #74

Closed adarnimrod closed 4 years ago

adarnimrod commented 4 years ago

Allow setting database connection parameters from the configuration file (like sslmode). We can get by for now with using environment variables that libpq uses but it would be nicer to use the configuration file. An option like params under the postgresql section that is a dictionary of the parameters is what I have in mind. Looking at https://docs.sqlalchemy.org/en/13/core/engines.html#custom-dbapi-args it seems like it's doable.

bochecha commented 4 years ago

The options in PostgreSQL seem to be https://www.postgresql.org/docs/current/libpq-connect.html#LIBPQ-PARAMKEYWORDS

It seems we can either pass them directly in the connecton URL, or as a dictionary for the connect_args argument.

They all seem to be strings (which makes sense given they can be passed in the URL or as environment variables) so we can even type-validate the config file while leaving the options arbitrary (to avoid having to maintain our own list of available options and updating it with each PostgreSQL release).