本文整理汇总了Python中mysql.Mysql.get_last_sql方法的典型用法代码示例。如果您正苦于以下问题:Python Mysql.get_last_sql方法的具体用法?Python Mysql.get_last_sql怎么用?Python Mysql.get_last_sql使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mysql.Mysql
的用法示例。
在下文中一共展示了Mysql.get_last_sql方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: post
# 需要导入模块: from mysql import Mysql [as 别名]
# 或者: from mysql.Mysql import get_last_sql [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(['name'])
if Base.check_parameter(set(self.request.arguments.keys()),essential_keys):
ret['code'] = 1
ret['message'] = '无效参数'
LOG.error('ERROR[in parameter invalid]')
break
group_name = ''.join(self.request.arguments['name'])
#timestamp = ''.join(self.request.arguments['timestamp'])
#secret = ''.join(self.request.arguments['secret'])
if Base.empty(group_name):
ret['code'] = 1
ret['message'] = '无效参数'
LOG.error('ERROR[parameter empty]')
break
#key = group_name + timestamp;
#secret_key = sha1(key).hexdigest()
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']
if Business.group_name_exist(group_name,system_id):
ret['code'] = 6
ret['message'] = '组名已存在'
LOG.error('ERROR[group exist]')
break
db = Mysql()
group_sql = "insert into entity_group (name,system_id) values ('%(group_name)s',%(system_id)d);"
try:
db.connect_master()
group_res = db.query(group_sql,group_name = group_name,system_id = system_id)
group_sql = db.get_last_sql()
group_id = db.get_last_id()
LOG.info('SQL[%s] - RES[%s] - INS[%d]' % (group_sql,group_res,group_id))
except DBException as e:
ret['code'] = 3
ret['message'] = '服务器错误'
LOG.error('ERROR[mysql error]')
break
else:
ret['code'] = 3
ret['message'] = '服务器错误'
LOG.error('ERROR[remote error]')
break
#.........这里部分代码省略.........
示例2: post
# 需要导入模块: from mysql import Mysql [as 别名]
# 或者: from mysql.Mysql import get_last_sql [as 别名]
#.........这里部分代码省略.........
if 0 == encode_body['code'] or 2 == encode_body['code']:
ret['code'] = 7
ret['message'] = 'token失效'
LOG.error('ERR[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']
if 0 != int(question_group):
if Business.group_id_exist(question_group,system_id) is False:
ret['code'] = 8
ret['message'] = '无效参数'
LOG.error('ERROR[group not exist]')
break
db = Mysql()
question_sql = "insert into entity_question (difficulty,question_docx,html,upload_time,update_time,question_type,subject_id,new_format,upload_id,upload_src,question_group,grade_id,state,is_single,question_type_id,answer_num,count_ref,paper_year,parent_question_id,count_options) values (%(level)d,'%(json)s','%(html)s',now(),now(),'%(type)s',%(subject_id)d,1,%(upload_id)d,%(upload_src)d,%(question_group)d,%(grade_id)d,'ENABLED',1,%(question_type_id)d,%(answer_num)d,0,0,0,%(count_options)d);"
link_topic_sql = "insert into link_question_topic (question_id,topic_id) values (%(q_id)d,%(t_id)d);"
link_chapter_sql = "insert into link_question_chapter (question_id,chapter_id) values (%(q_id)d,%(c_id)d);"
try:
db.connect_master()
db.start_event()
question_res = db.exec_event(question_sql,level = int(question_level),json = json_key,html = html_key,type = type_name,subject_id = int(subject_id),upload_id = int(system_id),upload_src = int(org_type),question_group = int(question_group),grade_id = int(grade_id),question_type_id = int(question_type),answer_num = answer_num,count_options = option_num)
question_sql = db.get_last_sql()
question_id = db.get_last_id()
LOG.info('RES[%s] - INS[%d]' % (question_res,question_id))
if Base.empty(question_topic) is False:
topic_list = question_topic.split(',')
for question_theme in topic_list:
topic_res = db.exec_event(link_topic_sql,q_id = int(question_id),t_id = int(question_theme))
topic_sql = db.get_last_sql()
topic_id = db.get_last_id()
LOG.info('RES[%s] - INS[%d]' % (topic_res,topic_id))
if not Base.empty(question_chapter):
chapter_res = db.exec_event(link_chapter_sql,q_id = int(question_id),c_id = int(question_chapter))
chapter_sql = db.get_last_sql()
chapter_id = db.get_last_id()
LOG.info('RES[%s] - INS[%d]' % (chapter_res,chapter_id))
except DBException as e:
db.rollback()
db.end_event()
ret['code'] = 3
ret['message'] = '服务器错误'
LOG.error('ERR[insert mysql error]')
break
else:
ret['code'] = 3
ret['message'] = '服务器错误'
LOG.error('ERROR[remote error]')
break
mongo = Mongo()