|
6 | 6 | def read_database_config(config_filename): |
7 | 7 | with open(config_filename) as configfile: |
8 | 8 | data = json.load(configfile) |
9 | | - return data['plugin_configuration']['database']['postgres'] |
| 9 | + if 'postgres' in data['plugin_configuration']['database']: |
| 10 | + # This basically translates an iRODS 4.2.x/4.3.x format |
| 11 | + # database configuration into iRODS 5.0 format |
| 12 | + return {k.replace("db_", "", 1): v for (k, v) in |
| 13 | + data['plugin_configuration']['database']['postgres'].items()} |
| 14 | + else: |
| 15 | + return data['plugin_configuration']['database'] |
10 | 16 |
|
11 | 17 |
|
12 | 18 | def get_connection_database(config): |
13 | 19 | try: |
14 | | - connection = psycopg2.connect(user=config['db_username'], |
15 | | - password=config['db_password'], |
16 | | - host=config['db_host'], |
17 | | - port=config['db_port'], |
18 | | - database=config['db_name']) |
| 20 | + connection = psycopg2.connect(user=config['username'], |
| 21 | + password=config['password'], |
| 22 | + host=config['host'], |
| 23 | + port=config['port'], |
| 24 | + database=config['name']) |
19 | 25 | except (Exception, psycopg2.Error) as error: |
20 | 26 | print("Error while connecting to database: ", error) |
21 | 27 | sys.exit(1) |
|
0 commit comments