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


Python Db.commit方法代码示例

本文整理汇总了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()
开发者ID:mcesar,项目名称:mpca,代码行数:57,代码来源:dependencias_estaticas.py

示例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()
开发者ID:ankitkariryaa,项目名称:NLP,代码行数:32,代码来源:scanCorpus.py

示例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)
开发者ID:Macman1234,项目名称:pythontumblrbot,代码行数:8,代码来源:db_test.py


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