From 13fb9f9c3d5b8eab44fde61648d88d911473e867 Mon Sep 17 00:00:00 2001 From: Maxime Beauchemin Date: Mon, 16 Nov 2015 11:01:36 -0800 Subject: [PATCH] Merge pull request #640 from SimpleHQ/allow_auto_commit_in_mysql_operator [MySqlOperator] Fix issue https://github.com/airbnb/airflow/issues/459 - mysql error 2014 GitOrigin-RevId: 3646c9b30d48105a15280965d5a3338ceccfef98 --- airflow/operators/mysql_operator.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/airflow/operators/mysql_operator.py b/airflow/operators/mysql_operator.py index 4a2085abd13..b8d56d5097e 100644 --- a/airflow/operators/mysql_operator.py +++ b/airflow/operators/mysql_operator.py @@ -24,13 +24,17 @@ class MySqlOperator(BaseOperator): @apply_defaults def __init__( self, sql, mysql_conn_id='mysql_default', parameters=None, - *args, **kwargs): + autocommit=False, *args, **kwargs): super(MySqlOperator, self).__init__(*args, **kwargs) self.mysql_conn_id = mysql_conn_id self.sql = sql + self.autocommit = autocommit self.parameters = parameters def execute(self, context): logging.info('Executing: ' + str(self.sql)) hook = MySqlHook(mysql_conn_id=self.mysql_conn_id) - hook.run(self.sql, parameters=self.parameters) + hook.run( + self.sql, + autocommit=self.autocommit, + parameters=self.parameters)