本文整理汇总了Python中couchdb.client.Server.delete方法的典型用法代码示例。如果您正苦于以下问题:Python Server.delete方法的具体用法?Python Server.delete怎么用?Python Server.delete使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类couchdb.client.Server
的用法示例。
在下文中一共展示了Server.delete方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from couchdb.client import Server [as 别名]
# 或者: from couchdb.client.Server import delete [as 别名]
class Model:
def __init__(self):
try:
self.__server = Server()
except:
print 'can not connect to Couchdb:%s'%(settings.c['db_url'])
self.__db = {}
self.__db_name = settings.c['db_name']
DEBUG.p(self.__db_name.items())
for (k, v) in self.__db_name.items():
try:
self.__db[v] = self.__server.create(v)
except:
self.__db[v] = self.__server[v]
def create(self, dbname):
return self.__server.create(dbname)
def delete(self, dbname):
try:
self.__server.delete(dbname)
except:
print 'database %s doeso not exist!!!'%(dbname)
def clearDB(self, dbname):
try:
self.__server.delete(dbname)
except:
print 'database %s doeso not exist!!!'%(dbname)
self.__db[v] = self.__server.create(dbname)
def getAllDoc(self):
return self.__db[self.__db_name['cover']]
def addOneDoc(self, doc):
keyStr = '%s:%s'%(doc['artist'], doc['album_name'])
doc['_id'] = hashlib.md5(keyStr.encode('ascii', 'ignore')).hexdigest()
print '_id:%s'%(doc['_id'])
doc_id, doc_rev = self.__db[self.__db_name['cover']].save(doc)
print 'addOneDoc done'
def delOneDoc(self, doc):
self.__db[self.__db_name['cover']].delete(doc)
def getById(self, artist, albumName):
keyStr = '%s:%s'%(artist, albumName)
_id = hashlib.md5(keyStr.encode('ascii', 'ignore')).hexdigest()
print _id
album = self.__db[self.__db_name['cover']].get(_id)
if album:
return dict(album)
return album
#map_fun = '''function(doc) {
# if (doc._id == '%s')
# emit(doc, null);
# }''' % (_id)
#albums = self.__db[self.__db_name['cover']].query(map_fun)
#for album in albums:
# return album.key
#return None
def getById2(self, id):
print id
album = self.__db[self.__db_name['cover']].get(id)
if album:
return dict(album)
return album
def getByKeyValue(self, key, value):
map_fun = '''function(doc) {
if (doc.%s == '%s')
emit(doc, null);
}''' % (key, value)
albums = self.__db[self.__db_name['cover']].query(map_fun)
for album in albums:
return album.key
return None
def getByArtist(self, artist):
map_fun = '''function(doc) {
if (doc.artist == '%s')
emit(doc, null);
}''' % (artist)
albums = self.__db[self.__db_name['cover']].query(map_fun)
for album in albums:
return album.key
return None
def getByAbbumName(self, albumName):
map_fun = '''function(doc) {
if (doc.album_name == '%s')
emit(doc, null);
}''' % (albumName)
albums = self.__db[self.__db_name['cover']].query(map_fun)
for album in albums:
return album.key
return None
#.........这里部分代码省略.........
示例2: Server
# 需要导入模块: from couchdb.client import Server [as 别名]
# 或者: from couchdb.client.Server import delete [as 别名]
from couchdb.client import Server
from glob import glob
from os import path
import json
import re
DB_SERVER = 'http://ben:[email protected]:5984'
DB_NAME = 'einfachjabber'
DB_REMOTE = 'http://ben:[email protected]:5984/einfachjabber'
server = Server(url=DB_SERVER)
server.delete(DB_NAME)
db = server.create(DB_NAME)
def defclient(osystem):
"""
Maps the OS short-names to their long pendants
and their default client
"""
system = ''
if osystem == 'android':
system = ['Android', 'beem']
if osystem == 'blackberry':
system = ['Blackberry', 'None']
if osystem == 'debian':
system = ['Debian', 'pidgin']
if osystem == 'iphone':
system = ['iPhone', 'None']
if osystem == 'macosx':
system = ['Mac OS X', 'ichat']
示例3: delete_dbs
# 需要导入模块: from couchdb.client import Server [as 别名]
# 或者: from couchdb.client.Server import delete [as 别名]
def delete_dbs():
s1 = Server(DEFAULT_STORE_ADMIN_URI)
s2 = Server(other_node)
s1.delete('testdb')
s2.delete('testdb')
示例4: Server
# 需要导入模块: from couchdb.client import Server [as 别名]
# 或者: from couchdb.client.Server import delete [as 别名]
from couchdb.client import Server
server = Server('http://localhost:5984')
try:
db = server.create('animals')
except:
db = server['animals']
print db.name
server.delete(db.name)