diff roundup/backends/back_postgresql.py @ 7696:4af0d235b570

feat(db): support using postgresql service connection file Add new service rdbms config option to set the service name to be used with a postgresql service connection file. This can be done using the PGSERVICE environment variable for a single instance tracker server. For a multi-instance server this per-tracker config option is needed. Note that settings (host, user, (db)name...) in config.ini file will override the service connection file setting. Also setting PGSERVICE and service will use the service setting.
author John Rouillard <rouilj@ieee.org>
date Tue, 07 Nov 2023 12:11:37 -0500
parents 5b41018617f2
children b41750bf9f03
line wrap: on
line diff
--- a/roundup/backends/back_postgresql.py	Sun Nov 05 23:01:29 2023 -0500
+++ b/roundup/backends/back_postgresql.py	Tue Nov 07 12:11:37 2023 -0500
@@ -176,8 +176,13 @@
 
     def sql_open_connection(self):
         db = connection_dict(self.config, 'database')
-        logging.getLogger('roundup.hyperdb').info(
-            'open database %r' % db['database'])
+        # database option always present: log it if not null
+        if db['database']:
+            logging.getLogger('roundup.hyperdb').info(
+                'open database %r' % db['database'])
+        if 'service' in db:  # only log if used
+            logging.getLogger('roundup.hyperdb').info(
+                'open database via service %r' % db['service'])
         try:
             conn = psycopg2.connect(**db)
         except psycopg2.OperationalError as message:

Roundup Issue Tracker: http://roundup-tracker.org/