示例#1
0
def get_user_profile(conn_func):
    conn = conn_func()
    sql = "select id, grade_id, exam from user_profile"
    A = pd.read_sql_query(sql, conn)
    A.columns = ["uid", "grade_id", "exam_type"]
    res = {}
    for _, row in A.iterrows():
        uid, grade_id, exam_type = row
        exam_kind = EXAM_KIND_MAP.get(grade_id, {}).get(exam_type, EXAM_KIND_DEFAULT)
        res[uid] = exam_kind
    return res
示例#2
0
def get_user_profile(conn_func):
    conn = conn_func()
    sql = 'select id, grade_id, exam from user_profile'
    A = pd.read_sql_query(sql, conn)
    A.columns = ['uid', 'grade_id', 'exam_type']
    res = {}
    for _, row in A.iterrows():
        uid, grade_id, exam_type = row
        exam_kind = EXAM_KIND_MAP.get(grade_id,
                                      {}).get(exam_type, EXAM_KIND_DEFAULT)
        res[uid] = exam_kind
    return res
示例#3
0
def get_origin(conn_func):
    conn = conn_func()
    cursor = conn.cursor()
    cursor.execute('select target_kind, target_id, '
                   'grade_id, exam_type from origin')
    origin = {}
    for qtype, qid, grade_id, etype in cursor.fetchall():
        ekind = EXAM_KIND_MAP.get(grade_id, EXAM_KIND_DEFAULT)
        if qtype not in origin:
            origin[qtype] = {}
        # 每道题目可能有多个 origin 来源
        origin[qtype].setdefault(qid, []).append((grade_id, etype, ekind))
    cursor.close()
    conn.close()
    return origin
示例#4
0
def get_origin(conn_func):
    conn = conn_func()
    cursor = conn.cursor()
    cursor.execute('select target_kind, target_id, '
                   'grade_id, exam_type from origin')
    origin = {}
    for qtype, qid, grade_id, etype in cursor.fetchall():
        ekind = EXAM_KIND_MAP.get(grade_id, {}).get(etype, EXAM_KIND_DEFAULT)
        if qtype not in origin:
            origin[qtype] = {}
        # 每道题目可能有多个 origin 来源
        origin[qtype].setdefault(qid, []).append((grade_id, etype, ekind))
    cursor.close()
    conn.close()
    return origin