def row2dict(row):
    """
    Convert a SQLAlchemy row/object to a dict, found on:
    http://stackoverflow.com/questions/
        1958219/convert-sqlalchemy-row-object-to-python-dict
    """
    d = {}
    for col_name in row.__table__.columns.keys():
        d[col_name] = getattr(row, col_name)

    return d