コード例 #1
0
ファイル: api_mysql_oa_select.py プロジェクト: TeaEra/CZT_Web
def get_oas():
    #
    sql_where = ADMIN_OA.get_where_from_fs(fs)
    sql_limit = ADMIN_OA.get_limit_from_fs(fs)
    #
    res = dict()
    res["oas"] = list()
    #
    try:
        conn, cur = ADMIN_OA.get_conn_for_mysql_oa()
        select_sql = "select * from t_account_manager"
        #
        select_sql += sql_where
        #
        select_sql += sql_limit
        all_data = UTIL.run_conn_select(cur, select_sql)
        #
        for row in all_data:
            res["oas"].append(UTIL.get_dict_in_utf8(row))
        #
        cur.close()
        conn.close()
        #
        UTIL.append_result_ok(res)
    except Exception, e:
        #
        UTIL.append_result_error(res, e)
コード例 #2
0
def get_file():
    #
    res = dict()
    #
    # file-path
    temp_dir = "/search/chenzhengtong/weixin-recom/tempFiles/"
    full_path = temp_dir + "single.csv"
    f = open(full_path)
    lines = f.readlines(100000)
    #
    format_list = ["main_type", "title", "url", "level"]
    #
    if not lines:
        print "error"
    else:
        try:
            #
            conn, cur = ADMIN_OA.get_conn_for_mysql_oa()
            #
            for each_line in lines:
                line = str.rstrip(each_line)
                temp_list = line.split(",")
                #
                content_list = list()
                content_list.append(
                    unicode(temp_list[0], "gbk").encode("gbk")
                )
                content_list.append(
                    unicode(temp_list[1], "gbk").encode("gbk")
                )
                content_list.append(
                    temp_list[2].split(CONST.OPENID_PREFIX)[1]
                )
                content_list.append(temp_list[3])
                #
                sql_ui = ADMIN_OA.get_ui_sql(content_list)
                #print sql_ui
                #
                cur.execute(sql_ui)
            #
            cur.close()
            conn.close()
            #
            UTIL.append_result_ok(res)
        except Exception, e:
            #
            UTIL.append_result_error(res, e)
コード例 #3
0
ファイル: api_mysql_oa_update.py プロジェクト: TeaEra/CZT_Web
def get_oas():
    #
    update_details = ADMIN_OA.get_update_details_from_fs(fs)
    #
    res = dict()
    res["oas"] = list()
    #
    try:
        conn, cur = ADMIN_OA.get_conn_for_mysql_oa()
        update_sql = "update t_account_manager set"
        #
        update_sql += update_details 
        #
        UTIL.run_conn_update(cur, update_sql)
        #
        cur.close()
        conn.close()
        #
        UTIL.append_result_ok(res)
    except Exception, e:
        #
        UTIL.append_result_error(res, e)
コード例 #4
0
def get_count():
    #
    sql_where = ADMIN_OA.get_where_from_fs(fs)
    #
    res = dict()
    #
    try:
        conn, cur = ADMIN_OA.get_conn_for_mysql_oa()
        sql_select = "select exists(select 1 from t_account_manager"
        sql_select += sql_where
        sql_select += ") as dup_check"
        #
        all_data = UTIL.run_conn_select(cur, sql_select)
        res["count"] = all_data
        #
        cur.close()
        conn.close()
        #
        UTIL.append_result_ok(res)
    except Exception, e:
        #
        UTIL.append_result_error(res, e)
コード例 #5
0
ファイル: api_mysql_oa_delete.py プロジェクト: TeaEra/CZT_Web
def get_res():
    #
    sql_where = ADMIN_OA.get_where_from_fs(fs)
    #
    res = dict()
    #
    try:
        conn, cur = ADMIN_OA.get_conn_for_mysql_oa()
        sql_delete = "delete from t_account_manager"
        #
        sql_delete += sql_where 
        #
        #print sql_delete
        TE_CUSTOM.run_sql(cur, sql_delete)
        #
        cur.close()
        conn.close()
        #
        UTIL.append_result_ok(res)
    except Exception, e:
        #
        UTIL.append_result_error(res, e)
コード例 #6
0
ファイル: api_mysql_oa_count.py プロジェクト: TeaEra/CZT_Web
def get_count():
    #
    sql_where = ADMIN_OA.get_where_from_fs(fs)
    #
    res = dict()
    #
    try:
        conn, cur = ADMIN_OA.get_conn_for_mysql_oa()
        select_sql = "select count(*) as total_num from t_account_manager"
        #
        select_sql += sql_where
        #
        all_data = UTIL.run_conn_select(cur, select_sql)
        res["count"] = all_data
        #
        cur.close()
        conn.close()
        #
        UTIL.append_result_ok(res)
    except Exception, e:
        #
        UTIL.append_result_error(res, e)
コード例 #7
0
ファイル: api_mysql_oa_insert.py プロジェクト: TeaEra/CZT_Web
def get_res():
    #
    insert_details = ADMIN_OA.get_insert_details_from_fs(fs)
    #
    res = dict()
    #
    try:
        conn, cur = ADMIN_OA.get_conn_for_mysql_oa()
        insert_sql = "insert into t_account_manager"
        #
        insert_sql += insert_details 
        #
        #print insert_sql
        TE_CUSTOM.run_sql(cur, insert_sql)
        #
        cur.close()
        conn.close()
        #
        UTIL.append_result_ok(res)
    except Exception, e:
        #
        UTIL.append_result_error(res, e)
コード例 #8
0
def get_file():
    #
    temp_dir = "/search/chenzhengtong/weixin-recom/tempFiles/"
    #
    file = fs["files"]
    #
    res = dict()
    #
    if file.filename:
        #
        # file-name
        #fn = file.filename
        fn = "single.csv"
        fn = os.path.basename(fn)
        #
        # file-path
        full_path = temp_dir + fn
        #
        #
        if os.path.isfile(full_path):
            os.remove(full_path)
        #
        #
        chunk = file.file.read()
        open(full_path, 'wb').write(chunk)
        #
        #
        f = open(full_path)
        lines = f.readlines(100000)
        oi_list = list()
        #
        if not lines:
            print "error"
        else:
            try:
                #
                conn, cur = ADMIN_OA.get_conn_for_mysql_oa()
                #
                for each_line in lines:
                    line = str.rstrip(each_line)
                    temp_list = line.split(",")
                    #
                    oi = temp_list[2].split(CONST.OPENID_PREFIX)[1]
                    oi_list.append(oi)
                #
                sql = "select count(*) as dup_num from t_account_manager where openid in "
                sql_in = ""
                for each_oi in oi_list[:-1]:
                    sql_in += "'" + each_oi + "',"
                sql_in += "'" + oi_list[-1] + "'"
                sql += "(" + sql_in + ")"
                #print sql
                all_data = UTIL.run_conn_select(cur, sql)
                res["count"] = all_data
                #
                cur.close()
                conn.close()
                #
                UTIL.append_result_ok(res)
            except Exception, e:
                #
                UTIL.append_result_error(res, e)