Skip to content

Commit

Permalink
fixes datetime issue when persisting logs
Browse files Browse the repository at this point in the history
- the current SQL INSERT statement contains a mix of datetime and string when inserting logs in DB, which seems to work fine on Mysql but fails on sqlite
  • Loading branch information
sv3ndk committed Nov 16, 2015
1 parent 49364e1 commit c4d0fe9
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions airflow/www/utils.py
Expand Up @@ -6,8 +6,8 @@
from io import BytesIO as IO
import functools
import gzip
import dateutil.parser as dateparser
import json

from flask import after_this_request, request, Response
from flask.ext.login import current_user
import wtforms
Expand Down Expand Up @@ -83,17 +83,23 @@ def wrapper(*args, **kwargs):
else:
user = 'anonymous'

session.add(
models.Log(
log = models.Log(
event=f.__name__,
task_instance=None,
owner=user,
extra=str(request.args.items()),
task_id=request.args.get('task_id'),
dag_id=request.args.get('dag_id'),
execution_date=request.args.get('execution_date')))
dag_id=request.args.get('dag_id'))

if 'execution_date' in request.args:
log.execution_date = dateparser.parse(
request.args.get('execution_date'))

session.add(log)
session.commit()

return f(*args, **kwargs)

return wrapper


Expand Down

0 comments on commit c4d0fe9

Please sign in to comment.