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


Python Mysql.connect_master方法代码示例

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


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

示例1: get_systematics

# 需要导入模块: from mysql import Mysql [as 别名]
# 或者: from mysql.Mysql import connect_master [as 别名]
	def get_systematics(question_id):
		
		mysql = Mysql()

		mysql.connect_master()
		
		query_sql = "select D.name as module_name,C.name as unit_name,B.name as topic_name from (select topic_id from link_question_topic where question_id=%(question_id)d)A left outer join (select id,name,unit_id from entity_topic)B on (A.topic_id=B.id) left outer join (select id,name,module_id from entity_unit)C on (B.unit_id=C.id) left outer join (select id,name from entity_module)D on (C.module_id=D.id);" 
		
		try:
			if mysql.query(query_sql,question_id = int(question_id)):

				res = mysql.fetchall()
				systematics_list = []

				for line in res:
					module = line[0]
					unit = line[1]
					topic = line[2]					
					systematics_dict = {'module':module,'unit':unit,'topic':topic}
					systematics_list.append(systematics_dict)

				return systematics_list
			else:
				return False

		except DBException as e:
			LOG.error('get systematics error [%s]' % e)
			raise CKException('get systematics error')
开发者ID:XDF-server,项目名称:exhibit,代码行数:30,代码来源:business.py

示例2: q_subject_list

# 需要导入模块: from mysql import Mysql [as 别名]
# 或者: from mysql.Mysql import connect_master [as 别名]
	def q_subject_list():

		mysql = Mysql()
		
		mysql.connect_master()

		query_sql = "select distinct subject from entity_question_new where type is not null;"	

		subject_list = []

		try:
			if mysql.query(query_sql):
				subject_tuple =  mysql.fetchall()
				
				for type in subject_tuple:
					tmp_tuple = (type[0])
					subject_list.append(tmp_tuple)
				return subject_list

			else:
				return None

		except DBException as e:
			LOG.error('get subject error [%s]' % e)
			raise CkException('get subject error')
开发者ID:XDF-server,项目名称:exhibit,代码行数:27,代码来源:business.py

示例3: _new_question

# 需要导入模块: from mysql import Mysql [as 别名]
# 或者: from mysql.Mysql import connect_master [as 别名]
	def _new_question(data):
	
		for i in range(1):
		
			mysql = Mysql()
			
			try:
				mysql.connect_master()
				
				search_sql = "select id,json,subject,type from entity_question_new where oldid = %(oldid)d;"
				if 0 == mysql.query(search_sql,oldid = int(data)):	
					return None
				else:
					question_set = mysql.fetch()

			except DBException as e:
				break

		newid = question_set[0]
		question_json = question_set[1]
		question_subject = question_set[2]
		question_type = question_set[3]

		new_question_dict = {}
		new_question_dict['q_new_id'] = newid
		new_question_dict['new_question'],new_question_dict['blank_num'] = Business.q_json_parse(question_type,question_json)
		new_question_dict['subject'] = question_subject
		#print new_question_dict
		return new_question_dict
开发者ID:XDF-server,项目名称:exhibit,代码行数:31,代码来源:exhibit_handler.py

示例4: get_question_by_id

# 需要导入模块: from mysql import Mysql [as 别名]
# 或者: from mysql.Mysql import connect_master [as 别名]
	def get_question_by_id(self,question_id):	
		
		mysql = Mysql()
			
		try:
			mysql.connect_master()

			search_sql = "select A.Knowledge,B.TypeValue,A.QuesAbility,A.QuesDiff,A.QuesBody,A.QuesAnswer,A.QuesParse from(select Knowledge,QuesType,QuesAbility,QuesDiff,QuesBody,QuesAnswer,QuesParse from paper.paper where ID=%(question_id)d union all select Knowledge,QuesType,QuesAbility,QuesDiff,QuesBody,QuesAnswer,QuesParse from paper.cz_paper where ID=%(question_id)d)A left outer join (select TypeId,TypeValue from paper.questype)B on (A.QuesType=B.TypeId);"

			if 0 == mysql.query(search_sql,question_id = int(question_id)):
				return None
			else:
				question_set = mysql.fetch()

		except DBException as e:
			pass

		question_ability_dict ={'1':'了解和识记','2':'理解和掌握','3':'简单应用','4':'综合应用'}
		question_diff_dict = {'1':'容易','2':'较易','3':'一般','4':'较难','5':'困难'}

		question_dict = {}
		
		question_dict['knowledge'] = question_set[0]
		question_dict['type'] = question_set[1]
		question_dict['ability'] = question_ability_dict[question_set[2]]
		question_dict['diff'] = question_diff_dict[question_set[3]]
	
		question_dict['body'] = question_set[4]
		question_dict['answer'] = question_set[5]
		question_dict['parse'] = question_set[6]

		return question_dict
开发者ID:XDF-server,项目名称:exhibit,代码行数:34,代码来源:exhibit_handler.py

示例5: get_group_list

# 需要导入模块: from mysql import Mysql [as 别名]
# 或者: from mysql.Mysql import connect_master [as 别名]
	def get_group_list(system_id):
	
		mysql = Mysql()

		mysql.connect_master()
		
		query_sql = "select A.id,A.name,B.num from (select id,name from entity_group where system_id=%(system_id)d or id=0)A left outer join (select question_group,count(1) as num from entity_question where upload_id=%(system_id)d group by question_group)B on (A.id=B.question_group);" 
		
		try:
			if mysql.query(query_sql,system_id = system_id):

				res = mysql.fetchall()

				group_list = []

				for line in res:
					group_id = line[0]
					group_name = line[1]
					question_num = int(line[2]) if line[2] else 0					
					group_dict = {'id':int(group_id),'name':group_name,'num':int(question_num)}
					group_list.append(group_dict)
			
				return group_list
			else:
				return False

		except DBException as e:
			LOG.error('check topic error [%s]' % e)
			raise CKException('check topic error')
开发者ID:XDF-server,项目名称:exhibit,代码行数:31,代码来源:business.py

示例6: q_mark_list

# 需要导入模块: from mysql import Mysql [as 别名]
# 或者: from mysql.Mysql import connect_master [as 别名]
	def q_mark_list():

		mysql = Mysql()
		
		mysql.connect_master()

		query_sql = "select id,name from link_question_mark where enable=1;"	

		mark_list = []

		try:
			if mysql.query(query_sql):
				mark_tuple =  mysql.fetchall()
				
				for mark in mark_tuple:
					tmp_tuple = (mark[0],mark[1])
					mark_list.append(tmp_tuple)
				return mark_list

			else:
				return None

		except DBException as e:
			LOG.error('get mark error [%s]' % e)
			raise CkException('get mark error')
开发者ID:XDF-server,项目名称:exhibit,代码行数:27,代码来源:business.py

示例7: is_seriess

# 需要导入模块: from mysql import Mysql [as 别名]
# 或者: from mysql.Mysql import connect_master [as 别名]
	def is_seriess(seriess_id):
		
		mysql = Mysql()
		
		mysql.connect_master()

		query_sql = "select 1 from entity_seriess where id = %(seriess_id)d;"
		
		try:
			if mysql.query(query_sql,seriess_id = int(seriess_id)):
				return True
			else:
				return False

		except DBException as e:
			LOG.error('check seriess error [%s]' % e)
			raise CkException('check seriess error')
开发者ID:XDF-server,项目名称:exhibit,代码行数:19,代码来源:business.py

示例8: is_topic

# 需要导入模块: from mysql import Mysql [as 别名]
# 或者: from mysql.Mysql import connect_master [as 别名]
	def is_topic(topic_id):
		
		mysql = Mysql()

		mysql.connect_master()
		
		query_sql = "select 1 from entity_topic where id = %(topic_id)d;" 
		
		try:
			if mysql.query(query_sql,topic_id = int(topic_id)):
				return True
			else:
				return False

		except DBException as e:
			LOG.error('check topic error [%s]' % e)
			raise CKException('check topic error')
开发者ID:XDF-server,项目名称:exhibit,代码行数:19,代码来源:business.py

示例9: chapter_id_exist

# 需要导入模块: from mysql import Mysql [as 别名]
# 或者: from mysql.Mysql import connect_master [as 别名]
	def chapter_id_exist(chapter_id):

		mysql = Mysql()

		mysql.connect_master()
		
		query_sql = "select 1 from entity_teaching_chapter where id='%(chapter_id)d';" 
		
		try:
			if mysql.query(query_sql,chapter_id = int(chapter_id)):
				return True
			else:
				return False

		except DBException as e:
			LOG.error('check chapter error [%s]' % e)
			raise CKException('check chapter error')
开发者ID:XDF-server,项目名称:api_resource,代码行数:19,代码来源:business.py

示例10: is_type

# 需要导入模块: from mysql import Mysql [as 别名]
# 或者: from mysql.Mysql import connect_master [as 别名]
	def is_type(type_id):
		
		mysql = Mysql()
		
		mysql.connect_master()

		query_sql = "select name from entity_question_type where type_id = %(type_id)d and enable = 1;"
		
		try:
			if mysql.query(query_sql,type_id = int(type_id)):
				return mysql.fetch()[0]
			else:
				return False

		except DBException as e:
			LOG.error('check type error [%s]' % e)
			raise CkException('check type error')
开发者ID:XDF-server,项目名称:exhibit,代码行数:19,代码来源:business.py

示例11: group_id_exist

# 需要导入模块: from mysql import Mysql [as 别名]
# 或者: from mysql.Mysql import connect_master [as 别名]
	def group_id_exist(group_id):
		
		mysql = Mysql()

		mysql.connect_master()
		
		query_sql = "select 1 from entity_group where id = '%(group_id)d';" 
		
		try:
			if mysql.query(query_sql,group_id = int(group_id)):
				return True
			else:
				return False

		except DBException as e:
			LOG.error('check topic error [%s]' % e)
			raise CKException('check topic error')
开发者ID:XDF-server,项目名称:exhibit,代码行数:19,代码来源:business.py

示例12: update_json_by_id

# 需要导入模块: from mysql import Mysql [as 别名]
# 或者: from mysql.Mysql import connect_master [as 别名]
	def update_json_by_id(oldid,json):
		
		mysql = Mysql()

		mysql.connect_master()

		query_sql = "update entity_question_new set json='%(question_json)s' where oldid=%(oldid)d;"	

		try:
			if mysql.query(query_sql,oldid = int(oldid),question_json = json):
				return True
			else:
				return False

		except DBException as e:
			LOG.error('update json error [%s]' % e)
			raise CkException('update json error')
开发者ID:XDF-server,项目名称:exhibit,代码行数:19,代码来源:business.py

示例13: q_subject_filter

# 需要导入模块: from mysql import Mysql [as 别名]
# 或者: from mysql.Mysql import connect_master [as 别名]
	def q_subject_filter(type,start,num):

		mysql = Mysql()

		mysql.connect_master()

		query_sql = "select oldid,subject from entity_question_new where subject = '%(type)s' limit %(start)d,%(num)d;"	

		try:
			if mysql.query(query_sql,type = type,start = start,num = num):
				return mysql.fetchall()

			else:
				return None

		except DBException as e:
			LOG.error('filtet type error [%s]' % e)
			raise CkException('filter type error')
开发者ID:XDF-server,项目名称:exhibit,代码行数:20,代码来源:business.py

示例14: verify

# 需要导入模块: from mysql import Mysql [as 别名]
# 或者: from mysql.Mysql import connect_master [as 别名]
	def verify(username,oldid,newid,verify):
		
		mysql = Mysql()

		mysql.connect_master()

		query_sql = "insert into entity_verify (username,oldid,newid,state) values ('%(username)s',%(oldid)d,%(newid)d,%(verify)d);"	

		try:
			if mysql.query(query_sql,username = username,oldid = int(oldid),newid = int(newid),verify = int(verify)):
				return mysql.get_last_id()

			else:
				return None

		except DBException as e:
			LOG.error('add mark error [%s]' % e)
			raise CkException('add mark error')
开发者ID:XDF-server,项目名称:exhibit,代码行数:20,代码来源:business.py

示例15: get_json_by_id

# 需要导入模块: from mysql import Mysql [as 别名]
# 或者: from mysql.Mysql import connect_master [as 别名]
	def get_json_by_id(oldid):
		
		mysql = Mysql()

		mysql.connect_master()

		query_sql = "select json from entity_question_new where oldid=%(oldid)d;"	

		try:
			if mysql.query(query_sql,oldid = int(oldid)):
				json = mysql.fetch()[0]
				return json
			else:
				return False

		except DBException as e:
			LOG.error('get json error [%s]' % e)
			raise CkException('get json error')
开发者ID:XDF-server,项目名称:exhibit,代码行数:20,代码来源:business.py


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