Skip to content

Commit

Permalink
Allow disabling periodic committing when inserting rows with DbApiHook
Browse files Browse the repository at this point in the history
```
>>> i = 1
>>> commit_every = 0
>>> bool(i % commit_every == 0)  # previously
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ZeroDivisionError: integer division or modulo by zero
>>> bool(commit_every and i % commit_every == 0)  # with this change
False
```
  • Loading branch information
underyx committed Mar 24, 2016
1 parent 58df89f commit 7a31361
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion airflow/hooks/dbapi_hook.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ def insert_rows(self, table, rows, target_fields=None, commit_every=1000):
target_fields,
",".join(values))
cur.execute(sql)
if i % commit_every == 0:
if commit_every and i % commit_every == 0:
conn.commit()
logging.info(
"Loaded {i} into {table} rows so far".format(**locals()))
Expand Down

0 comments on commit 7a31361

Please sign in to comment.