Skip to content

Commit

Permalink
Accept kwargs for mysql connection (#2226)
Browse files Browse the repository at this point in the history
  • Loading branch information
dstandish authored and dlstadther committed Sep 19, 2017
1 parent 00c6947 commit 25424d7
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions luigi/contrib/mysqldb.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class MySqlTarget(luigi.Target):

marker_table = luigi.configuration.get_config().get('mysql', 'marker-table', 'table_updates')

def __init__(self, host, database, user, password, table, update_id):
def __init__(self, host, database, user, password, table, update_id, **cnx_kwargs):
"""
Initializes a MySqlTarget instance.
Expand All @@ -50,6 +50,8 @@ def __init__(self, host, database, user, password, table, update_id):
:type password: str
:param update_id: an identifier for this data set.
:type update_id: str
:param cnx_kwargs: optional params for mysql connector constructor.
See https://dev.mysql.com/doc/connector-python/en/connector-python-connectargs.html.
"""
if ':' in host:
self.host, self.port = host.split(':')
Expand All @@ -62,6 +64,7 @@ def __init__(self, host, database, user, password, table, update_id):
self.password = password
self.table = table
self.update_id = update_id
self.cnx_kwargs = cnx_kwargs

def touch(self, connection=None):
"""
Expand Down Expand Up @@ -113,7 +116,8 @@ def connect(self, autocommit=False):
host=self.host,
port=self.port,
database=self.database,
autocommit=autocommit)
autocommit=autocommit,
**self.cnx_kwargs)
return connection

def create_marker_table(self):
Expand Down

0 comments on commit 25424d7

Please sign in to comment.