本文整理汇总了Python中db.Db.close方法的典型用法代码示例。如果您正苦于以下问题:Python Db.close方法的具体用法?Python Db.close怎么用?Python Db.close使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类db.Db
的用法示例。
在下文中一共展示了Db.close方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: load_evolutionary_dependencies_from_db
# 需要导入模块: from db import Db [as 别名]
# 或者: from db.Db import close [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
示例2: prets_fetchall
# 需要导入模块: from db import Db [as 别名]
# 或者: from db.Db import close [as 别名]
def prets_fetchall():
db = Db()
result = db.select("SELECT * FROM prets")
db.close()
resp = make_response(json.dumps(result))
resp.mimetype = 'application/json'
return resp
示例3: afficher_utilisateurs
# 需要导入模块: from db import Db [as 别名]
# 或者: from db.Db import close [as 别名]
def afficher_utilisateurs():
db=Db()
result=db.select('SELECT * FROM utilisateurs')
db.close()
resp = make_response(json.dumps(result),200)
resp.mimetype = 'application/json'
return resp
示例4: import_static_dependencies
# 需要导入模块: from db import Db [as 别名]
# 或者: from db.Db import close [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()
示例5: suppr_utilisateurs
# 需要导入模块: from db import Db [as 别名]
# 或者: from db.Db import close [as 别名]
def suppr_utilisateurs(id) :
db=Db()
result = db.execute('DELETE FROM utilisateurs WHERE id = %(id)s', {
'id' : id
})
db.close()
resp = make_response(json.dumps(result),200)
resp.mimetype='application/json'
return resp
示例6: prets_fetchone
# 需要导入模块: from db import Db [as 别名]
# 或者: from db.Db import close [as 别名]
def prets_fetchone(id):
db = Db()
result = db.select("SELECT * FROM prets WHERE id = %(id)s", {
'id': id
})
db.close()
if len(result) < 1:
return make_response("Not found", 404)
resp = make_response(json.dumps(result))
resp.mimetype = 'application/json'
return resp
示例7: suppr_prets
# 需要导入模块: from db import Db [as 别名]
# 或者: from db.Db import close [as 别名]
def suppr_prets(id):
db = Db()
result = db.execute("DELETE FROM prets WHERE id = %(id)s",{
'id':id,
})
db.close()
resp = make_response(json.dumps(result),204)
resp.mimetype = 'application/json'
return resp
示例8: pret_fetch
# 需要导入模块: from db import Db [as 别名]
# 或者: from db.Db import close [as 别名]
def pret_fetch(pret_id):
db = Db()
result = db.select("SELECT * FROM prets WHERE prets.pret_id = %(pret_id)s", {
'pret_id': pret_id
})
db.close()
if len(result) == 1:
resp = make_response(json.dumps(result[0]))
else:
resp = make_response(json.dumps({'error': 'Given pret_id not found in database.'}), 404)
resp.mimetype = 'application/json'
return resp
示例9: utilisateurs_id
# 需要导入模块: from db import Db [as 别名]
# 或者: from db.Db import close [as 别名]
def utilisateurs_id(id):
db=Db()
result = db.select('SELECT * FROM utilisateurs WHERE id = %(id)s', {
'id' : id
})
db.close()
if (len(result) != 1):
resp = make_response('Not Found', 404)
return resp
resp = make_response(json.dumps(result),200)
resp.mimetype = 'application/json'
return resp
示例10: modif_utilisateurs
# 需要导入模块: from db import Db [as 别名]
# 或者: from db.Db import close [as 别名]
def modif_utilisateurs(id):
data = request.get_json ()
db = Db()
result = db.execute("UPDATE utilisateurs SET nom = %(nom)s, prenom = %(prenom)s WHERE id = %(id)s",{
'id':id,
'nom':data["nom"],
'prenom':data["prenom"]
})
db.close()
resp = make_response(json.dumps(result),204)
resp.mimetype = 'application/json'
return resp
示例11: users_changeone
# 需要导入模块: from db import Db [as 别名]
# 或者: from db.Db import close [as 别名]
def users_changeone(id):
try :
data = request.get_json()
db = Db()
result = db.execute("UPDATE users SET nom = %(nom)s, prenom = %(prenom)s WHERE id=%(id)s",{
'nom' : data['nom'],
'prenom' : data['prenom'],
'id' : id
})
resp = make_response('', 204)
db.close()
return resp
except:
resp = make_response('', 400)
return resp
示例12: load_entities_from_db
# 需要导入模块: from db import Db [as 别名]
# 或者: from db.Db import close [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
示例13: prets_changeone
# 需要导入模块: from db import Db [as 别名]
# 或者: from db.Db import close [as 别名]
def prets_changeone(id):
try :
data = request.get_json()
db = Db()
result = db.execute("UPDATE prets SET qui = %(qui)s, quoi = %(quoi)s, statut = %(statut)s WHERE id=%(id)s",{
'qui' : data['qui'],
'quoi' : data['quoi'],
'statut' : data['statut'],
'id' : id
})
resp = make_response('', 204)
db.close()
return resp
except:
resp = make_response('', 400)
return resp
示例14: ajouter_utilisateurs
# 需要导入模块: from db import Db [as 别名]
# 或者: from db.Db import close [as 别名]
def ajouter_utilisateurs():
data = request.get_json ()
try :
db=Db()
result = db.execute('INSERT INTO utilisateurs ("nom", "prenom") VALUES (%(nom)s,%(prenom)s)', {
'nom' : data["nom"],
'prenom' : data["prenom"]
})
db.close()
resp = make_response(json.dumps(result))
resp.mimetype = 'application/json'
return resp
except :
resp = make_resonse('Bad Request', 400)
return resp
示例15: user_add
# 需要导入模块: from db import Db [as 别名]
# 或者: from db.Db import close [as 别名]
def user_add():
try :
data = request.get_json()
db = Db()
result = db.select("INSERT INTO users (nom, prenom) VALUES (%(nom)s,%(prenom)s) RETURNING id",{
'nom' : data['nom'],
'prenom' : data['prenom']
})
resp = make_response('', 201)
resp.mimetype = 'application/json'
resp.headers['Location'] = "/users/%d" % result[0]['id']
db.close()
return resp
except:
resp = make_response('', 400)
return resp