當前位置: 首頁>>代碼示例>>Python>>正文


Python DBManager.saveAll方法代碼示例

本文整理匯總了Python中DBManager.DBManager.saveAll方法的典型用法代碼示例。如果您正苦於以下問題:Python DBManager.saveAll方法的具體用法?Python DBManager.saveAll怎麽用?Python DBManager.saveAll使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在DBManager.DBManager的用法示例。


在下文中一共展示了DBManager.saveAll方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1:

# 需要導入模塊: from DBManager import DBManager [as 別名]
# 或者: from DBManager.DBManager import saveAll [as 別名]
		db = conn.createDB()
		conn.saveAllViews()
	except couchdb.http.ResourceNotFound:
	   	print "Database doesn't exist. We'll go ahead and create it."
	   	db = conn.createDB()
	   	conn.saveAllViews()
else:
	db = conn.db

max_num_articles=config.getint('boston_globe','max_num_articles')
articles_at_a_time=config.getint('boston_globe','articles_at_a_time')
size = 0
lastArticleDate=""
results = db.view('globe/last_article_date')
for row in results:       
 	lastArticleDate = row['value']

if (lastArticleDate ==""):
	lastArticleDate = "20100101"

while size<max_num_articles:
	latestArticles = boston_globe.fetchLatestArticlesFromAPI(size, lastArticleDate)
	if (len(latestArticles) ==0):
		break
	cleanArticles = geoprocessor.filterAndCleanArticles(latestArticles, conn)

	conn.saveAll(cleanArticles)
	size += articles_at_a_time


print "Done adding articles from the API"
開發者ID:c4fcm,項目名稱:Boston-Attention-Mapping,代碼行數:33,代碼來源:add_articles_from_API.py


注:本文中的DBManager.DBManager.saveAll方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。