日韩久久久精品,亚洲精品久久久久久久久久久,亚洲欧美一区二区三区国产精品 ,一区二区福利

純Python開發(fā)的nosql數(shù)據(jù)庫(kù)CodernityDB介紹和使用實(shí)例

系統(tǒng) 1791 0

看看這個(gè)logo,有些像python的小蛇吧 。這次介紹的數(shù)據(jù)庫(kù)codernityDB是純python開發(fā)的。

純Python開發(fā)的nosql數(shù)據(jù)庫(kù)CodernityDB介紹和使用實(shí)例_第1張圖片

先前用了下tinyDB這個(gè)本地?cái)?shù)據(jù)庫(kù),也在一個(gè)api服務(wù)中用了下,一開始覺得速度有些不給力,結(jié)果一看實(shí)現(xiàn)的方式,真是太鳥了,居然就是json的存儲(chǔ),連個(gè)二進(jìn)制壓縮都沒有。? 這里介紹的CodernityDB 也是純開發(fā)的一個(gè)小數(shù)據(jù)庫(kù)。

CodernityDB是開源的,純Python語(yǔ)言(沒有第三方依賴),快速,多平臺(tái)的NoSQL型數(shù)據(jù)庫(kù)。它有可選項(xiàng)支持HTTP服務(wù)版本(CodernityDB-HTTP),和Python客戶端庫(kù)(CodernityDB-PyClient),它目標(biāo)是100%兼容嵌入式的版本。

主要特點(diǎn)

1.Pyhon原生支持
2.多個(gè)索引
3.快(每秒可達(dá)50 000次insert操作)
4.內(nèi)嵌模式(默認(rèn))和服務(wù)器模式(CodernityDB-HTTP),加上客戶端庫(kù)(CodernityDB-PyClient),能夠100%兼容
5.輕松完成客戶的存儲(chǔ)

CodernityDB數(shù)據(jù)庫(kù)操作代碼實(shí)例:

復(fù)制代碼 代碼如下:

Insert(simple)
?
from CodernityDB.database import Database
?
db = Database('/tmp/tut1')
db.create()
?
insertDict = {'x': 1}
print db.insert(insertDict)
?
?

?
Insert
?
from CodernityDB.database import Database
from CodernityDB.hash_index import HashIndex
?
class WithXIndex(HashIndex):
??? def __init__(self, *args, **kwargs):
??????? kwargs['key_format'] = 'I'
??????? super(WithXIndex, self).__init__(*args, **kwargs)
?
??? def make_key_value(self, data):
??????? a_val = data.get("x")
??????? if a_val is not None:
??????????? return a_val, None
??????? return None
?
??? def make_key(self, key):
??????? return key
?
db = Database('/tmp/tut2')
db.create()
?
x_ind = WithXIndex(db.path, 'x')
db.add_index(x_ind)
?
print db.insert({'x': 1})


?
Count
?
from CodernityDB.database import Database
?
db = Database('/tmp/tut1')
db.open()
?
print db.count(db.all, 'x')

?
Get
?
from CodernityDB.database import Database
?
db = Database('/tmp/tut2')
db.open()
?
print db.get('x', 1, with_doc=True)

?
Delete
?
from CodernityDB.database import Database
?
db = Database('/tmp/tut2')
db.open()
?
curr = db.get('x', 1, with_doc=True)
doc? = curr['doc']
?
db.delete(doc)


?
Update
?
from CodernityDB.database import Database
?
db = Database('/tmp/tut2')
db.create()
?
curr = db.get('x', 1, with_doc=True)
doc? = curr['doc']
?
doc['Updated'] = True
db.update(doc)


更多文章、技術(shù)交流、商務(wù)合作、聯(lián)系博主

微信掃碼或搜索:z360901061

微信掃一掃加我為好友

QQ號(hào)聯(lián)系: 360901061

您的支持是博主寫作最大的動(dòng)力,如果您喜歡我的文章,感覺我的文章對(duì)您有幫助,請(qǐng)用微信掃描下面二維碼支持博主2元、5元、10元、20元等您想捐的金額吧,狠狠點(diǎn)擊下面給點(diǎn)支持吧,站長(zhǎng)非常感激您!手機(jī)微信長(zhǎng)按不能支付解決辦法:請(qǐng)將微信支付二維碼保存到相冊(cè),切換到微信,然后點(diǎn)擊微信右上角掃一掃功能,選擇支付二維碼完成支付。

【本文對(duì)您有幫助就好】

您的支持是博主寫作最大的動(dòng)力,如果您喜歡我的文章,感覺我的文章對(duì)您有幫助,請(qǐng)用微信掃描上面二維碼支持博主2元、5元、10元、自定義金額等您想捐的金額吧,站長(zhǎng)會(huì)非常 感謝您的哦!!!

發(fā)表我的評(píng)論
最新評(píng)論 總共0條評(píng)論
主站蜘蛛池模板: 三穗县| 乌拉特前旗| 普定县| 博野县| 永寿县| 龙海市| 罗源县| 仁怀市| 永兴县| 嵩明县| 遂平县| 龙海市| 延边| 陆丰市| 准格尔旗| 丁青县| 临汾市| 和平县| 兴仁县| 万载县| 紫阳县| 手游| 潼南县| 沁源县| 武汉市| 邛崃市| 玉溪市| 德保县| 昂仁县| 巴南区| 玉树县| 巴塘县| 临桂县| 星子县| 封丘县| 友谊县| 普兰县| 德化县| 景洪市| 韶山市| 阜城县|