Quantcast
Channel: Planet PostgreSQL
Viewing all articles
Browse latest Browse all 9758

Bruce Momjian: Centralizing Connection Parameters

$
0
0

Hard-coding database connection parameters in application code has many downsides:

  • changes require application modifications
  • changes are hard to deploy and customize
  • central connection parameter management is difficult

Libpq does support the setting of connection parameters via environment variables, and this often avoids many of the down-sides of hard-coding database connection parameters. (I already covered the importance of libpq as the common Postgres connection library used by all client interfaces except jdbc.)

However, there is another libpq feature that makes connection parameter sharing even easier: pg_service.conf. This file allows you to name a group of connection parameters and reference the parameters by specifying the name when connecting. By placing this file in a network storage device, you can easily centrally-control application connections. Change the file, and every new database connection sees the changes. While you can store passwords in pg_service.conf, everyone who can access the file can see those passwords, so you would probably be better off using libpq's password file.


Viewing all articles
Browse latest Browse all 9758

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>