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


Python Db.query方法代码示例

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


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

示例1: load_evolutionary_dependencies_from_db

# 需要导入模块: from db import Db [as 别名]
# 或者: from db.Db import query [as 别名]
def load_evolutionary_dependencies_from_db():
	db = Db()
	repository_id = constants.repository_map[args.repository]
	types = 'CN,CM,FE,MT'
	if args.coarse_grained:
		types = 'CL,IN'
	graphs_ed = {}
	cursor = db.query("""select g.id, g.source, g.max_entities, g.min_confidence, 
			g.min_support, g.min_date, g.types, de.entidade1, de.entidade2, e.caminho
		from dependencias_evolucionarias de 
			inner join grafos_de g on de.grafo = g.id 
			inner join entidades e on de.entidade2 = e.id 
		where g.repositorio = %s and g.types = %s""", 
		(repository_id,types))
	for (id, source, max_entitites, min_confidence, min_support, min_date, types, entity1, entity2, e2_path) in cursor:
		if id not in graphs_ed:
			graphs_ed[id] = {
				'source': source, 
				'max_entitites': max_entitites, 
				'min_confidence': min_confidence, 
				'min_support': min_support, 
				'min_date': min_date, 
				'types': types,
				'dependencies': {}
			}
		if entity1 not in graphs_ed[id]['dependencies']:
			graphs_ed[id]['dependencies'][entity1] = []
		entity2_java_name = to_java_convention(e2_path, args.repository, True)
		graphs_ed[id]['dependencies'][entity1].append(entity2_java_name)
	db.close()
	return graphs_ed
开发者ID:mcesar,项目名称:mpca,代码行数:33,代码来源:dependencias_estaticas.py

示例2: load_entities_from_db

# 需要导入模块: from db import Db [as 别名]
# 或者: from db.Db import query [as 别名]
def load_entities_from_db():
	db = Db()
	repository_id = constants.repository_map[args.repository]
	prefixes = constants.repository_prefixes[args.repository]['db']
	db_entities = {}
	sql_args = (repository_id,)
	prefixes_str = ''
	for prefix in prefixes:
		sql_args += (prefix + '%',)
		if len(prefixes_str) > 0: prefixes_str += ' or '
		prefixes_str += 'caminho like %s'
	cursor = db.query(
		"select id, caminho from entidades where repositorio = %s and (" + prefixes_str + ")", sql_args)
	for (id, path) in cursor:
		key = to_java_convention(path, args.repository, True)
		if not key in db_entities: db_entities[key] = {'id': id, 'path': path}
	db.close()
	return db_entities
开发者ID:mcesar,项目名称:mpca,代码行数:20,代码来源:dependencias_estaticas.py

示例3: in_str

# 需要导入模块: from db import Db [as 别名]
# 或者: from db.Db import query [as 别名]
	(s, types) = in_str(args.types.split(','))

	db = Db()

	repository_id = constants.repository_map[args.repository]

	graph = {}
	entities = []
	previous_id = None

	if args.store_on_db:
		graphs = db.query("""select id 
			from grafos_de 
			where repositorio=%s 
				and source=%s 
				and max_entities=%s 
				and min_confidence=%s 
				and min_support=%s 
				and min_date=%s 
				and types=%s""",
				(repository_id,args.source,args.max_entities,args.min_confidence,args.min_support,args.min_date,args.types), cursor=False)
		if len(graphs) == 0:
			graph_id = db.insert("insert into grafos_de(repositorio,source,max_entities,min_confidence,min_support,min_date,types) values (%s,%s,%s,%s,%s,%s,%s)",
				(repository_id,args.source,args.max_entities,args.min_confidence,args.min_support,args.min_date,args.types))
		else:
			graph_id = graphs[0][0]
			db.delete("delete from dependencias_evolucionarias where grafo = %s", (graph_id,))

	cursor = db.query(sql[args.source].replace('?in?', s), (repository_id, args.min_date) + types)

	for (id, entity) in cursor:
		if previous_id != id:
开发者ID:mcesar,项目名称:mpca,代码行数:34,代码来源:construtor_grafo.py


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