Skip to content

Commit

Permalink
Added default port behaviour for Redshift (#2474)
Browse files Browse the repository at this point in the history
* PostgresTarget default port defined as class variable, so Targets which subclass PostgresTarget (e.g. RedshiftTarget) can define their own default port
  • Loading branch information
gregroberts authored and dlstadther committed Jul 26, 2018
1 parent f9a99dc commit f0fdca7
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
7 changes: 5 additions & 2 deletions luigi/contrib/postgres.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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
Expand Down
3 changes: 3 additions & 0 deletions luigi/contrib/redshift.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down

0 comments on commit f0fdca7

Please sign in to comment.