纯Python开发的nosql数据库CodernityDB介绍和使用实例
2014-10-23 10:54
1026 查看
看看这个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()
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)
您可能感兴趣的文章:
- PHP对MongoDB[NoSQL]数据库的操作
- 大数据时代的数据库选择:SQL还是NoSQL?
- 8种主流NoSQL数据库系统特性对比和最佳应用场景
- 初识NoSQL NoSql数据库入门 NoSql数据库基础知识
- NoSQL反模式 - 文档数据库篇
- 最新统计排名前十的SQL和NoSQL数据库排行榜
- NoSQL和Redis简介及Redis在Windows下的安装和使用教程
- MongoDB系列教程(一):NoSQL起源
- 关于NoSQL之MongoDB的一些总结
- NoSQL数据库的分布式算法详解
- 深入解析NoSQL数据库的分布式算法(图文详解)
- NoSQL开篇之为什么要使用NoSQL
- 8 种常用的 NoSQL 数据库系统对比分析
- NoSQL 数据库你应该了解的 10 件事
相关文章推荐
- 纯Python开发的nosql数据库CodernityDB介绍和使用实例
- 使用ADO封装类的数据库程序开发实例
- CGI介绍及使用Python来开发CGI应用示例
- 使用ADO封装类的数据库程序开发实例[第二版] (上)
- Cocos2d-x开发实例介绍帧动画使用
- NoSQL数据库Redis(REmote DIctionary Server)使用介绍和特性
- 使用ADO封装类的数据库程序开发实例(上)
- 使用ADO封装类的数据库程序开发实例(下)
- 使用ADO封装类的数据库程序开发实例[第二版] (下)
- 使用ADO封装类的数据库程序开发实例[第二版] (上zz)
- Python读取图片EXIF信息类库介绍和使用实例
- 使用ADO封装类的数据库程序开发实例(上)
- NoSQL数据库使用实例
- Python开发环境Wing IDE使用教程:部分调试功能介绍
- 使用ADO封装类的数据库程序开发实例[第二版] (上)
- 使用ADO封装类的数据库程序开发实例
- 详解NoSQL数据库使用实例
- 转 成真 使用ADO封装类的数据库程序开发实例[第二版] (上)
- Python ORM框架SQLAlchemy学习笔记之映射类使用实例和Session会话介绍
- Python开发环境Wing IDE使用教程:部分调试功能介绍