Skip to content
This repository has been archived by the owner on Apr 18, 2018. It is now read-only.

Commit

Permalink
make kohlrabi tolerant of receiving extra fields
Browse files Browse the repository at this point in the history
  • Loading branch information
eklitzke committed Nov 29, 2010
1 parent fdecb3e commit 7e7b347
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion kohlrabi/db.py
Expand Up @@ -71,9 +71,18 @@ def load_report(cls, data, date=None):
if hasattr(cls, 'column_map'):
datum = dict((cls.column_map[k], v) for k, v in datum.iteritems())
datum['date'] = date

# SQLAlchemy will throw an exception if we give it any extra
# columns, so make sure the dataset it pruned to columns that
# actually exist
for k in datum.keys():
# XXX: this is a really crude heuristic
if not hasattr(cls, k):
del datum[k]

session.add(cls(**datum))
session.commit()

def dates(cls):
return (row.date for row in session.query(cls).group_by(cls.date))

Expand Down

0 comments on commit 7e7b347

Please sign in to comment.