JsonDB的一个使用实例

JsonDB是一个python实现的基于JSON格式的轻量级数据库开源项目,你可以通过github进行下载和安装,项目地址是:https://github.com/hujiang001/jsonDB/

作者提供了完整的参考文档,而且是中文的,所以上手非常容易,这是他的中文文档的地址: https://github.com/hujiang001/jsonDB/wiki/reference-document 。 当前在项目工程里面也是包含了这个文档:reference.md。

项目还提供了一个使用的实例,在example.py中,下面我们把这个例子粘贴出来,上面有详细的注释,可以看出使用起来还是挺简单的:

#!usr/bin/env python
# -*- coding: utf-8 -*-

from database import JSONDB

if __name__=="__main__":
    shopDb = JSONDB('shop_db',hashSize=1)  #create shop db
    userDb = JSONDB('sellerDb',hashSize=1) #create user db

    #specify key
    shopDb.ensureKey('shop',['id'])
    shopDb.ensureKey('goods',['id'])
    userDb.ensureKey('seller',['id','name'])
    userDb.ensureKey('customer',['id','name'])

    #for debugging, you can start perfDot and open debug switch
    shopDb.perfDotStart()
    userDb.perfDotStart()
    shopDb.debugSwitch(1)
    userDb.debugSwitch(1)

    #insert data
    #here we insert s
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值