From 1002e18a5acd1cd2b18ce10279b32f0dea6576b6 Mon Sep 17 00:00:00 2001 From: irfan-alam Date: Thu, 7 Jan 2021 16:42:42 +0530 Subject: [PATCH 1/3] added statement_timeout to connection_config --- tap_postgres/db.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tap_postgres/db.py b/tap_postgres/db.py index c7711c42..96286735 100644 --- a/tap_postgres/db.py +++ b/tap_postgres/db.py @@ -49,6 +49,9 @@ def open_connection(conn_config, logical_replication=False): 'connect_timeout': 30 } + if conn_config.get('statement_timeout'): + cfg['options'] = '-c statement_timeout={}'.format(conn_config['statement_timeout']) + if conn_config.get('sslmode'): cfg['sslmode'] = conn_config['sslmode'] From 65cd156b7baa4f40ee81bb09341256cd04299745 Mon Sep 17 00:00:00 2001 From: irfan-alam Date: Fri, 8 Jan 2021 08:18:09 +0530 Subject: [PATCH 2/3] s added for seconds, checks added for 0 --- tap_postgres/db.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tap_postgres/db.py b/tap_postgres/db.py index 96286735..1f8bab27 100644 --- a/tap_postgres/db.py +++ b/tap_postgres/db.py @@ -49,8 +49,9 @@ def open_connection(conn_config, logical_replication=False): 'connect_timeout': 30 } - if conn_config.get('statement_timeout'): - cfg['options'] = '-c statement_timeout={}'.format(conn_config['statement_timeout']) + statement_timeout = conn_config.get('statement_timeout') + if statement_timeout is not None: + cfg['options'] = f'-c statement_timeout={statement_timeout}s' if conn_config.get('sslmode'): cfg['sslmode'] = conn_config['sslmode'] From 05bb9e8b54ecc6f69af96f4acc45839633de73e1 Mon Sep 17 00:00:00 2001 From: irfan-alam Date: Wed, 13 Jan 2021 17:54:51 +0530 Subject: [PATCH 3/3] making config options generic so that it accept any valid postgres options --- tap_postgres/db.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/tap_postgres/db.py b/tap_postgres/db.py index 1f8bab27..b36fd922 100644 --- a/tap_postgres/db.py +++ b/tap_postgres/db.py @@ -49,9 +49,7 @@ def open_connection(conn_config, logical_replication=False): 'connect_timeout': 30 } - statement_timeout = conn_config.get('statement_timeout') - if statement_timeout is not None: - cfg['options'] = f'-c statement_timeout={statement_timeout}s' + cfg['options'] = ' '.join(map('-c {0}'.format, conn_config.get('options',[]))) if conn_config.get('sslmode'): cfg['sslmode'] = conn_config['sslmode']