def row_to_dict(row):
    """
    Translate sql alchemy row to dict

    Args:
    row: SQL alchemy class

    Returns:
      data_dict(dict): data as dictionary
    """
    if not row:
        return {}
    if hasattr(row, "__table__"):
        return dict((col, getattr(row, col))
                    for col in row.__table__.columns.keys())
    else:
        ret = {}
        for table in row:
            if table:
                ret[table.__tablename__] = dict(
                    (col, getattr(table, col)) for col
                    in table.__table__.columns.keys())
        return ret