本文整理汇总了Python中webp.utils.db.DB.get_value方法的典型用法代码示例。如果您正苦于以下问题:Python DB.get_value方法的具体用法?Python DB.get_value怎么用?Python DB.get_value使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类webp.utils.db.DB
的用法示例。
在下文中一共展示了DB.get_value方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: create
# 需要导入模块: from webp.utils.db import DB [as 别名]
# 或者: from webp.utils.db.DB import get_value [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)
示例2: createinit
# 需要导入模块: from webp.utils.db import DB [as 别名]
# 或者: from webp.utils.db.DB import get_value [as 别名]
def createinit(request):
module_flag = request.GET['module_flag']
db = DB()
module_id = db.get_value("select id from module where flag='%s'" % module_flag)
db.execute("select id,name from tac where module_id=%d" % module_id)
res = db.fetchall()
_list = []
for id, name in res:
tac = Tac(id=id, name=name)
_list.append(tac)
dic = user_utils.user_info_context(request)
dic['tacs'] = _list
return render_to_response("html/nonmarked/fieldstat/create.html", dic)
示例3: create
# 需要导入模块: from webp.utils.db import DB [as 别名]
# 或者: from webp.utils.db.DB import get_value [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')