Mercurial > p > roundup > code
comparison 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 |
comparison
equal
deleted
inserted
replaced
| 7695:2be7a8f66ea7 | 7696:4af0d235b570 |
|---|---|
| 174 # used by some code to switch styles of query | 174 # used by some code to switch styles of query |
| 175 implements_intersect = 1 | 175 implements_intersect = 1 |
| 176 | 176 |
| 177 def sql_open_connection(self): | 177 def sql_open_connection(self): |
| 178 db = connection_dict(self.config, 'database') | 178 db = connection_dict(self.config, 'database') |
| 179 logging.getLogger('roundup.hyperdb').info( | 179 # database option always present: log it if not null |
| 180 'open database %r' % db['database']) | 180 if db['database']: |
| 181 logging.getLogger('roundup.hyperdb').info( | |
| 182 'open database %r' % db['database']) | |
| 183 if 'service' in db: # only log if used | |
| 184 logging.getLogger('roundup.hyperdb').info( | |
| 185 'open database via service %r' % db['service']) | |
| 181 try: | 186 try: |
| 182 conn = psycopg2.connect(**db) | 187 conn = psycopg2.connect(**db) |
| 183 except psycopg2.OperationalError as message: | 188 except psycopg2.OperationalError as message: |
| 184 raise hyperdb.DatabaseError(message) | 189 raise hyperdb.DatabaseError(message) |
| 185 | 190 |
