本文整理汇总了Python中db.Db.commit方法的典型用法代码示例。如果您正苦于以下问题:Python Db.commit方法的具体用法?Python Db.commit怎么用?Python Db.commit使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类db.Db
的用法示例。
在下文中一共展示了Db.commit方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: import_static_dependencies
# 需要导入模块: from db import Db [as 别名]
# 或者: from db.Db import commit [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: Db
# 需要导入模块: from db import Db [as 别名]
# 或者: from db.Db import commit [as 别名]
db = Db()
if len(sys.argv) != 2:
raise Exception("Usage: run.py [init|process]")
if sys.argv[1] == "init":
db.initCounts()
sys.exit()
elif sys.argv[1] != "process":
raise Exception("Invalid mode!")
# split and validate words
re_valid = re.compile(r"^[a-z]+$")
re_split = re.compile(r"[\s.,:;/()\"&-]+")
charcounts = collections.defaultdict(lambda:0)
for line in sys.stdin:
for word in re_split.split(line):
last_char = "@"
if re_valid.match(word):
db.incrementWordCount(word)
for char in word:
charcounts[char] += 1
charcounts[last_char+char] += 1
last_char = char
charcounts["@"] += 1
for k,v in charcounts.iteritems():
db.setCharCount(k,v)
# important:
db.commit()
示例3: test_db_commit_performed_correctly
# 需要导入模块: from db import Db [as 别名]
# 或者: from db.Db import commit [as 别名]
def test_db_commit_performed_correctly(self):
db = Db(self.conn, self.sql)
db.setup(3)
self.assertEqual(self.conn.commit_count, 0)
db.commit()
self.assertEqual(self.conn.commit_count, 1)