From 4c5c4f2d18348e8aa3f50e182f4d356b1036870d Mon Sep 17 00:00:00 2001 From: Greg Roberts Date: Thu, 26 Jul 2018 14:36:59 +0100 Subject: [PATCH] Added default port behaviour for Redshift (#2474) * PostgresTarget default port defined as class variable, so Targets which subclass PostgresTarget (e.g. RedshiftTarget) can define their own default port --- luigi/contrib/postgres.py | 7 +++++-- luigi/contrib/redshift.py | 3 +++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/luigi/contrib/postgres.py b/luigi/contrib/postgres.py index d06b2a1f69..ec8b72df16 100644 --- a/luigi/contrib/postgres.py +++ b/luigi/contrib/postgres.py @@ -106,11 +106,14 @@ class PostgresTarget(luigi.Target): """ marker_table = luigi.configuration.get_config().get('postgres', 'marker-table', 'table_updates') + # if not supplied, fall back to default Postgres port + DEFAULT_DB_PORT = 5432 + # Use DB side timestamps or client side timestamps in the marker_table use_db_timestamps = True def __init__( - self, host, database, user, password, table, update_id, port=5432 + self, host, database, user, password, table, update_id, port=None ): """ Args: @@ -126,7 +129,7 @@ def __init__( self.host, self.port = host.split(':') else: self.host = host - self.port = port + self.port = port or self.DEFAULT_DB_PORT self.database = database self.user = user self.password = password diff --git a/luigi/contrib/redshift.py b/luigi/contrib/redshift.py index 5302c3d5f0..a1c5c43172 100644 --- a/luigi/contrib/redshift.py +++ b/luigi/contrib/redshift.py @@ -135,6 +135,9 @@ class RedshiftTarget(postgres.PostgresTarget): 'marker-table', 'table_updates') + # if not supplied, fall back to default Redshift port + DEFAULT_DB_PORT = 5439 + use_db_timestamps = False