本文整理汇总了Python中DB.exists方法的典型用法代码示例。如果您正苦于以下问题:Python DB.exists方法的具体用法?Python DB.exists怎么用?Python DB.exists使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DB
的用法示例。
在下文中一共展示了DB.exists方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: run
# 需要导入模块: import DB [as 别名]
# 或者: from DB import exists [as 别名]
def run(self):
datastore = DB();
readFile = open(self.infile, 'r')
count = 0
for line in readFile:
count = count + 1
readFile = open(self.infile, 'r')
i = 0;
for line in readFile:
i = i + 1
authorId = line[:line.find('\t')].strip()
if not datastore.exists(authorId):
authorName = line[line.find('\t') + 1:].strip()
surname = authorName[authorName.rfind(' ') + 1:].strip()
u = URL('http://forebears.io/surnames/' + surname, authorId)
datastore.insert(authorId, authorName, u.fetch())
print 'Thread ' + self.infile[8:] + ' is ' + str(i * 100.0 / count) + '% completed..'
示例2: DB
# 需要导入模块: import DB [as 别名]
# 或者: from DB import exists [as 别名]
from DB import *
datastore = DB()
filep = open('outfiles/outfile', 'r')
for line in filep:
aid = line[:line.find('\t')]
name = line[line.find('\t') + 1 : line.rfind('\t')]
country = line[line.rfind('\t') + 1:].strip()
if not datastore.exists(aid):
datastore.insert(aid, name, country)