当前位置: 首页>>代码示例>>Python>>正文


Python DB.exe_commit方法代码示例

本文整理汇总了Python中webp.utils.db.DB.exe_commit方法的典型用法代码示例。如果您正苦于以下问题:Python DB.exe_commit方法的具体用法?Python DB.exe_commit怎么用?Python DB.exe_commit使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在webp.utils.db.DB的用法示例。


在下文中一共展示了DB.exe_commit方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: delete

# 需要导入模块: from webp.utils.db import DB [as 别名]
# 或者: from webp.utils.db.DB import exe_commit [as 别名]
def delete(request):
    module_flag = request.GET["module_flag"]
    func_flag = request.GET["func_flag"]
    func_tac_id = int(request.GET["func_tac_id"])
    db = DB()
    
    tac = Tac.from_db_by_func_tac_id("taca_id", func_tac_id)

    Tac.del_func_tac_rel(func_tac_id = func_tac_id)

    a_keys, a_values = tac.keys_values

    shell = Shell(
        module_flag = module_flag,
        func_flag = func_flag,
        tac_name = tac.name,
        args = {
            'k': a_keys, 'v': a_values,
            't': 2,
            }
        )

    log_path = shell.gen_log_path()

    db.exe_commit("insert into func_tac_log(func_tac_id,path,kind) values(%d,'%s',0)" % (func_tac_id, log_path))

    res = shell.execute()
    if not res:
        db.exe_commit("update func_tac_rel set status=-1,description='Interface error' where id=%d" % func_tac_id)
    return HttpResponse("1")
开发者ID:Superjom,项目名称:webp,代码行数:32,代码来源:fieldstat.py

示例2: create

# 需要导入模块: from webp.utils.db import DB [as 别名]
# 或者: from webp.utils.db.DB import exe_commit [as 别名]
    def create(dic):
        db = DB()
        keys = tuple([ dic[key] for key in ('module_id', 'name', 'description', 
                'key_1', 'value_1', 'key_2', 'value_2',
                'key_3', 'value_3', 'key_4', 'value_4',
                'key_5', 'value_5',) ])

        sql = u"insert into tac(module_id,name,description,key_1,value_1,key_2,value_2,key_3,value_3,key_4,value_4,key_5,value_5) values(%d,'%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s')" % keys
        db.exe_commit(sql)
        return True
开发者ID:Superjom,项目名称:webp,代码行数:12,代码来源:tac.py

示例3: create

# 需要导入模块: from webp.utils.db import DB [as 别名]
# 或者: from webp.utils.db.DB import exe_commit [as 别名]
def create(request):
    db = DB()
    dic = user_utils.user_info_context(request)
    user = dic['user']
    module_flag = request.GET['module_flag']
    func_flag = request.GET['func_flag']
    taca_id = int(request.GET['taca_id'])
    tacb_id = int(request.GET['tacb_id'])
    func_id = db.get_value("select id from func where flag='%s'" % func_flag)
    count = db.get_value("select count(*) from func_tac_rel where func_id=%d and taca_id=%d and tacb_id=%d" % (func_id, taca_id, tacb_id))

    if count > 0: return HttpResponse("该策略任务已经存在")

    taca = Tac.from_db(id=taca_id)
    tacb = Tac.from_db(id=tacb_id)

    sql = "insert into func_tac_rel(func_id,taca_id,tacb_id,user_id,status) values(%d,%d,%d,%d,0)" % (func_id, taca_id, tacb_id, user.id)
    _debug_print(sql)
    db.exe_commit(sql)

    tac_name = "%s_%s" % (taca.name, tacb.name)

    sql = "select id from func_tac_rel where func_id=%d and taca_id=%d and tacb_id=%d" % (func_id, taca_id, tacb_id)
    _debug_print(sql)
    func_tac_id = db.get_value(sql)

    a_keys, a_values = taca.keys_values
    b_keys, b_values = tacb.keys_values
    
    shell = Shell(
        module_flag = module_flag,
        func_flag = func_flag,
        tac_name = tac_name,
        args = {
            'k': a_keys, 'v': a_values,
            'x': b_keys, 'y': b_values,
            't': 1,
            }
        )

    log_path = shell.gen_log_path()

    sql = "insert into func_tac_log(func_tac_id,path,kind) values(%d,'%s',1)" % (func_tac_id, log_path) 
    _debug_print(sql)
    db.exe_commit(sql)

    res = shell.execute()
    if res:
        return HttpResponse('1')
    else:
        sql = "update func_tac_rel set status=-1,description='Interface error' where id=%d" % func_tac_id
        _debug_print(sql)
        db.exe_commit(sql)
开发者ID:Superjom,项目名称:webp,代码行数:55,代码来源:fieldcase.py

示例4: create

# 需要导入模块: from webp.utils.db import DB [as 别名]
# 或者: from webp.utils.db.DB import exe_commit [as 别名]
def create(request):
    db = DB()
    dic = user_utils.user_info_context(request)
    user = dic['user']
    module_flag = request.GET['module_flag']
    func_flag = request.GET['func_flag']
    taca_id = int(request.GET['taca_id'])
    try:
        tacb_id = int(request.GET['tacb_id'])
    except:
        tacb_id = 0

    func_id = db.get_value("select id from func where flag='%s'" % func_flag)

    count = db.get_value("select count(*) from func_tac_rel where func_id=%d and taca_id=%d and tacb_id=%d" % (func_id, taca_id, tacb_id))

    if count > 0:
        return HttpResponse("该策略任务已经存在")

    taca = Tac.from_db(taca_id)
    tacb = Tac.from_db(tacb_id) if tacb_id != 0 else None

    if tacb_id != 0:
        count = db.get_value("select count(*) from func_tac_rel where func_id=$func_id and taca_id in ($taca_id,$tacb_id) and status=1 and tacb_id is null")
        if count < 2: return HttpResponse("单个策略的统计数据尚未生成")
        sql = "insert into func_tac_rel(func_id,taca_id,tacb_id,user_id,status) values(%d,%d,%d,%d,0)" % (func_id, taca_id, tacb_id, user.id)

    else:
        sql = "insert into func_tac_rel(func_id,taca_id,user_id,status) values(%d,%d,%d,0)" % (func_id, taca_id, user.id)

    _debug_print("sql: " + sql)
    db.exe_commit(sql)

    tac_name = "%s_%s" % (taca.name, tacb.name) if tacb_id != 0 else taca.name

    sql = ("select id from func_tac_rel where func_id=%d and taca_id=%d and tacb_id=" + \
            str(tacb_id) if tacb_id != 0 else "null") % taca_id
    _debug_print(sql)
    func_tac_id = db.get_value(sql)

    shell = Shell(
        module_flag = module_flag,
        func_flag = func_flag,
        tac_name = tac_name,
        args = {
            't':1,
            }
        )

    log_path = shell.gen_log_path()

    sql = "insert into func_tac_log(func_tac_id,path,kind) values(%d,'%s',1)" % (func_tac_id, log_path) 
    _debug_print(sql)
    db.exe_commit(sql)
    # <<<<<<<<<<<<<<<<<<<<<<<
    a_keys, a_values = taca.keys_values

    args = {
        'k': a_keys, 'v': a_values,
    }

    if tacb_id != 0:
        # generate keys and values
        b_keys, b_values = tacb.keys_values
        args.update( {
            'x': b_keys,
            'y': b_values,
            })
    shell.update_args(args)

    res = shell.execute()
    if not res:
        sql = "update func_tac_rel set status=-1,description='Interface error' where id=%d" % func_tac_id
        _debug_print(sql)
        db.exe_commit(sql)
        return HttpResponse("0")
    return HttpResponse('1')
开发者ID:Superjom,项目名称:webp,代码行数:79,代码来源:googlepr.py


注:本文中的webp.utils.db.DB.exe_commit方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。