国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > Python > 正文

純Python開發的nosql數據庫CodernityDB介紹和使用實例

2020-02-23 06:06:45
字體:
來源:轉載
供稿:網友

看看這個logo,有些像python的小蛇吧 。這次介紹的數據庫codernityDB是純python開發的。

先前用了下tinyDB這個本地數據庫,也在一個api服務中用了下,一開始覺得速度有些不給力,結果一看實現的方式,真是太鳥了,居然就是json的存儲,連個二進制壓縮都沒有。  這里介紹的CodernityDB 也是純開發的一個小數據庫。

CodernityDB是開源的,純Python語言(沒有第三方依賴),快速,多平臺的NoSQL型數據庫。它有可選項支持HTTP服務版本(CodernityDB-HTTP),和Python客戶端庫(CodernityDB-PyClient),它目標是100%兼容嵌入式的版本。

主要特點

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

CodernityDB數據庫操作代碼實例:

代碼如下:
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()

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 贡山| 延长县| 南开区| 当雄县| 南靖县| 临夏县| 西林县| 临邑县| 稷山县| 甘泉县| 靖江市| 七台河市| 武城县| 甘肃省| 三河市| 永和县| 峡江县| 微山县| 宾阳县| 蒲江县| 永靖县| 汤阴县| 汽车| 延庆县| 榆树市| 牟定县| 治县。| 葵青区| 永州市| 阿尔山市| 天柱县| 湖州市| 诸城市| 堆龙德庆县| 西乌珠穆沁旗| 永清县| 祁连县| 科尔| 营山县| 普宁市| 郯城县|