本文整理汇总了Python中mysql.Mysql.end方法的典型用法代码示例。如果您正苦于以下问题:Python Mysql.end方法的具体用法?Python Mysql.end怎么用?Python Mysql.end使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mysql.Mysql
的用法示例。
在下文中一共展示了Mysql.end方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: post
# 需要导入模块: from mysql import Mysql [as 别名]
# 或者: from mysql.Mysql import end [as 别名]
def post(self):
for i in range(1):
LOG.info('API IN[%s]' % (self.__class__.__name__))
LOG.info('PARAMETER IN[%s]' % self.request.arguments)
ret = {'code':'','message':''}
essential_keys = set(['id'])
if Base.check_parameter(set(self.request.arguments.keys()),essential_keys):
ret['code'] = 1
ret['message'] = '无效参数'
LOG.error('ERROR[in parameter invalid]')
break
group_id = ''.join(self.request.arguments['id'])
if Base.empty(group_id):
ret['code'] = 1
ret['message'] = '无效参数'
LOG.error('ERROR[parameter empty]')
break
configer = Configer()
remote_host = configer.get_configer('REMOTE','host')
remote_port = configer.get_configer('REMOTE','port')
remote_uri = configer.get_configer('REMOTE','uri')
remote_url = "http://%s:%s/%s" % (remote_host,remote_port,remote_uri)
token = self.get_cookie("teacher_id")
LOG.info('TOKEN[%s]' % token)
if token is None:
ret['code'] = 6
ret['message'] = '无效参数'
LOG.error('ERROR[token empty]')
break
post_data = {'token' : token}
client = httpclient.AsyncHTTPClient()
response = yield gen.Task(client.fetch,remote_url,method = 'POST',body = urllib.urlencode(post_data))
#response = Http.post(remote_url,post_data)
LOG.info('REMOTE RES CODE[%d]' % response.code)
if 200 == response.code:
encode_body = json.loads(response.body)
if 0 == encode_body['code'] or 2 == encode_body['code']:
ret['code'] = 7
ret['message'] = '无效参数'
LOG.error('ERROR[token not exist]')
break
if 1 == encode_body['code']:
subject_id = encode_body['subject_id']
grade_id = encode_body['grade_id']
system_id = encode_body['system_id']
org_type = encode_body['org_type']
db = Mysql()
group_sql = "delete from entity_group where id=%(group_id)d and system_id=%(system_id)d;"
question_sql = "update entity_question set question_group=0 where question_group=%(question_group)d and upload_id=%(system_id)d;"
try:
db.connect_master()
db.start_event()
group_res = db.exec_event(group_sql,group_id = int(group_id),system_id = int(system_id))
if group_res is False:
ret['code'] = 7
ret['message'] = '无效参数'
LOG.error('ERROR[group not exist]')
break
group_sql = db.get_last_sql()
LOG.info('SQL[%s] - RES[%s]' % (group_sql,group_res))
question_res = db.exec_event(question_sql,question_group = int(group_id),system_id = int(system_id))
question_sql = db.get_last_sql()
LOG.info('SQL[%s] - RES[%s]' % (question_sql,question_res))
except DBException as e:
db.rollback()
db.end_event()
ret['code'] = 3
ret['message'] = '服务器错误'
LOG.error('ERROR[mysql error]')
break
else:
db.rollback()
db.end(event)
ret['code'] = 3
#.........这里部分代码省略.........