本文整理汇总了Python中couchdb.Server.config方法的典型用法代码示例。如果您正苦于以下问题:Python Server.config方法的具体用法?Python Server.config怎么用?Python Server.config使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类couchdb.Server
的用法示例。
在下文中一共展示了Server.config方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: loadCouchDB
# 需要导入模块: from couchdb import Server [as 别名]
# 或者: from couchdb.Server import config [as 别名]
def loadCouchDB(db_name, view_name, excel_name):
tweet_dict = {}
couch_server = Server("http://115.146.94.12:5984")
couch_server.resource.credentials = ('admin', 'admin')
couch_server.config()
db = couch_server[db_name]
wb = Workbook()
ws = wb.active
ws.title = "range names"
rowid = 1
for row in db.view(view_name):
coordinate = re.sub(r"\[|\]", "", str(row.key))
# write coordinate
col = get_column_letter(1)
ws.cell('%s%s'%(col, rowid)).value = coordinate
#write polarity
col = get_column_letter(2)
ws.cell('%s%s'%(col, rowid)).value = getPolarity(row.value)
#write text
col = get_column_letter(3)
ws.cell('%s%s'%(col, rowid)).value = row.value
rowid += 1
ws = wb.create_sheet()
ws.title = 'coordinate'
wb.save(filename = excel_name)
return tweet_dict
示例2: loadCouchDB
# 需要导入模块: from couchdb import Server [as 别名]
# 或者: from couchdb.Server import config [as 别名]
def loadCouchDB(db_name, view_name, start_key, end_key):
tweet_dict = []
couch_server = Server("http://115.146.94.12:5984")
couch_server.resource.credentials = ("admin", "admin")
couch_server.config()
db = couch_server[db_name]
start_reading_db_time = time.time()
try:
logger.info(socket.gethostname() + " Start reading " + view_name + " on database")
for row in db.view(view_name, reduce=False, startkey=start_key, endkey=end_key):
text = row.value
if re.search(r"[^\x00-\x7F]+", text) is None:
tweet_dict.append(row.key + "@@##$$" + text)
except:
logger.error(socket.gethostname() + " Reading " + view_name + " error.")
end_reading_db_time = time.time()
reading_db_time = end_reading_db_time - start_reading_db_time
logger.info(socket.gethostname() + " Finished reading " + view_name + ".")
logger.info(
socket.gethostname()
+ " Read "
+ view_name
+ " from "
+ start_key
+ " to "
+ end_key
+ " for "
+ str(reading_db_time)
+ "s."
)
return tweet_dict
示例3: Server
# 需要导入模块: from couchdb import Server [as 别名]
# 或者: from couchdb.Server import config [as 别名]
__author__ = 'josh'
from couchdb import Server
import couchdb
if __name__ == "__main__":
import sys
source_name = sys.argv[1]
dbname = sys.argv[2]
couch_server = Server("http://115.146.94.12:5984")
couch_server.resource.credentials = ('admin', 'admin')
couch_server.config()
try:
couch_db = couch_server.create(dbname)
except couchdb.http.PreconditionFailed, e:
couch_db = couch_server[dbname]
for line in open(source_name):
line = line.strip()
if line == '':
continue
else:
(key, count) = line.split(" ###### ")
couch_db[key] = {"count": count}