本文整理汇总了Python中db.Db.insert方法的典型用法代码示例。如果您正苦于以下问题:Python Db.insert方法的具体用法?Python Db.insert怎么用?Python Db.insert使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类db.Db
的用法示例。
在下文中一共展示了Db.insert方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: import_static_dependencies
# 需要导入模块: from db import Db [as 别名]
# 或者: from db.Db import insert [as 别名]
def import_static_dependencies(db_entities, classes, coarse_grained):
db = Db()
table_suffix = ""
if coarse_grained:
table_suffix = "_coarse_grained"
if not args.dont_store:
db.delete("""
delete from dependencias{}
where entidade1 in (select id from entidades where repositorio=%s)""".format(table_suffix),
(constants.repository_map[args.repository],))
dep_map = {}
for c in classes.values():
if coarse_grained:
if c['name'] in db_entities:
caller_id = db_entities[c['name']]['id']
for d in c['dependencies']:
if d in db_entities and not args.dont_store:
calle_id = db_entities[d]['id']
db.insert('insert into dependencias_coarse_grained values (%s,%s)', (caller_id, calle_id))
if args.verbose and not args.not_found:
print(c['name'])
else:
anonymous_inner_class = re.search('\$\d+$', c['name'])
if args.verbose and args.not_found and not anonymous_inner_class:
print(c['name'])
else:
for e in c['entities']:
if e['name'] in db_entities:
caller_id = db_entities[e['name']]['id']
for d in e['dependencies']:
calle_id = find_id_in_class_or_superclasses(d, classes, db_entities, e)
if calle_id:
#print(db_entities[e['name']]['id'], db_entities[d]['id'])
if not args.dont_store and '{}-{}'.format(caller_id, calle_id) not in dep_map:
db.insert('insert into dependencias values (%s,%s)', (caller_id, calle_id))
dep_map['{}-{}'.format(caller_id, calle_id)] = True
#else:
# if args.verbose: print(d)
if args.verbose and not args.not_found:
print(e['name'])
else:
# ignore entities not supported by historage
anonymous_inner_class = re.search('\$\d+\.', e['name'])
compiler_generated_element = re.search('access\$\d+\(', e['name']) or re.search('\.this\$\d+', e['name'])
default_constructor = is_default_constructor(e['name'])
# prints feature names not found in db
if args.verbose and args.not_found and not anonymous_inner_class and not compiler_generated_element and not default_constructor:
print(e['name'])
db.commit()
db.close()
示例2: prets_create
# 需要导入模块: from db import Db [as 别名]
# 或者: from db.Db import insert [as 别名]
def prets_create():
data = request.get_json()
try:
insert_data = {
'pret_quoi': data['pret_quoi'],
'pret_qui': data['pret_qui'],
'pret_etat': data['pret_etat']
}
except KeyError:
resp = make_response(json.dumps({'error': 'Form data is incomplete.'}), 400)
resp.mimetype = 'application/json'
return resp
db = Db()
pret_id = db.insert('INSERT INTO prets(pret_quoi, pret_qui, pret_etat) VALUES(%(pret_quoi)s, %(pret_qui)s, %(pret_etat)s)', 'pret_id', insert_data)
db.close()
resp = make_response(json.dumps({
'pret_id': pret_id
}), 201)
resp.mimetype = 'application/json'
return resp
示例3: reversed
# 需要导入模块: from db import Db [as 别名]
# 或者: from db.Db import insert [as 别名]
if re.search('\.dot$', file):
file_name = file.rpartition('/')[2]
file_repository = None
for k in reversed(sorted(constants.repository_map.keys())):
if file_name.startswith(k):
file_repository = constants.repository_map[k]
break
if repository != None and file_repository != repository:
continue
db.execute("delete from clusters_entidades where cluster in " + \
"(select id from clusters where grafo in " + \
"(select id from grafos where arquivo = %s))", (file_name,))
db.execute("delete from clusters where grafo in " + \
"(select id from grafos where arquivo = %s)", (file_name,))
db.execute("delete from grafos where arquivo = %s", (file_name,))
graph_id = db.insert('insert into grafos(repositorio, arquivo) values (%s,%s)',
(file_repository,file_name))
with open(file) as f:
print file
for line in f:
match = re.search('subgraph (.+) {', line)
if match:
cluster_name = match.group(1)
cluster_id = db.insert('insert into clusters(grafo, nome) values (%s,%s)',
(graph_id, cluster_name))
match = re.search('\"(\d+)\"\[', line)
if match:
db.insert('insert into clusters_entidades(cluster, entidade) values (%s,%s)',
(cluster_id, match.group(1)))
db.commit()
db.close()
示例4: len
# 需要导入模块: from db import Db [as 别名]
# 或者: from db.Db import insert [as 别名]
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:
increment_support(graph, entities, args.max_entities)
previous_id = id
entities.clear()
entities.append(entity)
increment_support(graph, entities, args.max_entities)
calculate_confidence(graph)