コード例 #1
0
def get_applications(where, pageable):
    pageable = gen_pageable(pageable)
    sql = 'SELECT * FROM application {} {}'.format(where, pageable)
    sql_total_count = 'SELECT COUNT(*) FROM application {}'.format(where)

    conn = g.db.pool.connection()
    with conn.cursor() as cursor:
        cursor.execute(sql)
        records = cursor.fetchall()
        application_list = []
        for record in records:
            application = Application()
            application.from_record(record)
            application_list.append(application.__dict__)

        cursor.execute(sql_total_count)
        total_count = cursor.fetchone()
    conn.close()

    return total_count[0], application_list
コード例 #2
0
ファイル: task_db.py プロジェクト: shunshunmao00/cubeai
def get_tasks(where, pageable):
    pageable = gen_pageable(pageable)
    sql = 'SELECT * FROM task {} {}'.format(where, pageable)
    sql_total_count = 'SELECT COUNT(*)  FROM task {}'.format(where)

    conn = g.db.pool.connection()
    with conn.cursor() as cursor:
        cursor.execute(sql)
        records = cursor.fetchall()
        task_list = []
        for record in records:
            task = Task()
            task.from_record(record)
            task_list.append(task.__dict__)

        cursor.execute(sql_total_count)
        total_count = cursor.fetchone()
    conn.close()

    return total_count[0], task_list
コード例 #3
0
ファイル: deployment_db.py プロジェクト: shunshunmao00/cubeai
def get_deployments(where, pageable):
    pageable = gen_pageable(pageable)
    sql = 'SELECT * FROM deployment {} {}'.format(where, pageable)
    sql_total_count = 'SELECT COUNT(*)  FROM deployment {}'.format(where)

    conn = g.db.pool.connection()
    with conn.cursor() as cursor:
        cursor.execute(sql)
        records = cursor.fetchall()
        deployment_list = []
        for record in records:
            deployment = Deployment()
            deployment.from_record(record)
            deployment_list.append(deployment.__dict__)

        cursor.execute(sql_total_count)
        total_count = cursor.fetchone()
    conn.close()

    return total_count[0], deployment_list
コード例 #4
0
def get_messages(where, pageable):
    pageable = gen_pageable(pageable)
    sql = 'SELECT * FROM message {} {}'.format(where, pageable)
    sql_total_count = 'SELECT COUNT(*)  FROM message {}'.format(where)

    conn = g.db.pool.connection()
    with conn.cursor() as cursor:
        cursor.execute(sql)
        records = cursor.fetchall()
        message_list = []
        for record in records:
            message = Message()
            message.from_record(record)
            message_list.append(message.__dict__)

        cursor.execute(sql_total_count)
        total_count = cursor.fetchone()
    conn.close()

    return total_count[0], message_list
コード例 #5
0
ファイル: user_db.py プロジェクト: shunshunmao00/cubeai
def get_users(where, pageable):
    pageable = gen_pageable(pageable)
    sql = 'SELECT * FROM user {} {}'.format(where, pageable)
    sql_total_count = 'SELECT COUNT(*)  FROM user {}'.format(where)

    conn = g.db.pool.connection()
    with conn.cursor() as cursor:
        cursor.execute(sql)
        records = cursor.fetchall()
        user_list = []
        for record in records:
            user = User()
            user.from_record(record)
            user.remove_internal_values()
            user_list.append(user.__dict__)

        cursor.execute(sql_total_count)
        total_count = cursor.fetchone()
    conn.close()

    return total_count[0], user_list
コード例 #6
0
def get_credit_historys(where, pageable):
    pageable = gen_pageable(pageable)
    sql = 'SELECT * FROM credit_history {} {}'.format(where, pageable)
    sql_total_count = 'SELECT COUNT(*)  FROM credit_history {}'.format(where)

    conn = g.db.pool.connection()
    with conn.cursor() as cursor:
        cursor.execute(sql)
        records = cursor.fetchall()

        credit_history_list = []
        for record in records:
            credit_history = CreditHistory()
            credit_history.from_record(record)
            credit_history_list.append(credit_history.__dict__)

        cursor.execute(sql_total_count)
        total_count = cursor.fetchone()
    conn.close()

    return total_count[0], credit_history_list