純Python開發(fā)的nosql數(shù)據(jù)庫CodernityDB介紹和使用實(shí)例
看看這個logo,有些像python的小蛇吧 。這次介紹的數(shù)據(jù)庫codernityDB是純python開發(fā)的。

先前用了下tinyDB這個本地數(shù)據(jù)庫,也在一個api服務(wù)中用了下,一開始覺得速度有些不給力,結(jié)果一看實(shí)現(xiàn)的方式,真是太鳥了,居然就是json的存儲,連個二進(jìn)制壓縮都沒有。 這里介紹的CodernityDB 也是純開發(fā)的一個小數(shù)據(jù)庫。
CodernityDB是開源的,純Python語言(沒有第三方依賴),快速,多平臺的NoSQL型數(shù)據(jù)庫。它有可選項(xiàng)支持HTTP服務(wù)版本(CodernityDB-HTTP),和Python客戶端庫(CodernityDB-PyClient),它目標(biāo)是100%兼容嵌入式的版本。
主要特點(diǎn)
1.Pyhon原生支持
2.多個索引
3.快(每秒可達(dá)50 000次insert操作)
4.內(nèi)嵌模式(默認(rèn))和服務(wù)器模式(CodernityDB-HTTP),加上客戶端庫(CodernityDB-PyClient),能夠100%兼容
5.輕松完成客戶的存儲
CodernityDB數(shù)據(jù)庫操作代碼實(shí)例:
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)
- JPA之使用JPQL語句進(jìn)行增刪改查
- mysql5.7.19 解壓版安裝教程詳解(附送純凈破解中文版SQLYog)
- 3步搞定純真IP數(shù)據(jù)導(dǎo)入到MySQL的方法詳解
- 用純CSS+DIV寫的漂亮Flash幻燈片及SQL標(biāo)簽教程!
- SQL刪除語句DROP、TRUNCATE、 DELETE 的區(qū)別
- mybatis-plus配置控制臺打印完整帶參數(shù)SQL語句的實(shí)現(xiàn)
- 在IDEA中安裝MyBatis Log Plugin插件,執(zhí)行mybatis的sql語句(推薦)
- 基于JPQL實(shí)現(xiàn)純SQL語句方法詳解
相關(guān)文章
python游戲測試工具自動化遍歷游戲中所有關(guān)卡
這篇文章主要為大家介紹了python游戲測試工具自動化遍歷游戲中所有關(guān)卡示例詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪2022-06-06
Python使用Pygame實(shí)現(xiàn)時鐘效果
這篇文章主要為大家詳細(xì)介紹了Python使用Pygame實(shí)現(xiàn)時鐘效果,文中示例代碼介紹的非常詳細(xì),具有一定的參考價值,感興趣的小伙伴們可以參考一下2021-08-08
Python中如何實(shí)現(xiàn)真正的按位取反運(yùn)算
按位取反是位運(yùn)算符,而位運(yùn)算符是應(yīng)用在兩個數(shù)的運(yùn)算上,會對數(shù)字的二進(jìn)制所有位數(shù)進(jìn)行從低到高的運(yùn)算,下面這篇文章主要給大家介紹了關(guān)于Python中如何實(shí)現(xiàn)真正的按位取反運(yùn)算的相關(guān)資料,需要的朋友可以參考下2023-02-02
Python 編碼處理-str與Unicode的區(qū)別
本文主要介紹Python 編碼處理的問題,這里整理了相關(guān)資料,并詳細(xì)說明如何處理編碼問題,有需要的小伙伴可以參考下2016-09-09

