jsonstore是通过http公开的json文档的轻量级数据库。
jsonstore的Python项目详细描述
一个JSON文档的无模式数据库,通过REST API公开,使用灵活的匹配算法实现搜索。
快速入门:
$ pip install jsonstore $ jsonstore * Running on http://127.0.0.1:31415/
创建文档:
$ curl -v http://127.0.0.1:31415/ -d '{"foo":"bar","baz":{"count":42}}' < HTTP/1.0 201 Created < Location: http://127.0.0.1:31415/72dcf1ee-8efd-4d7f-8ca1-2eda2bf85099 < etag: "348f16ee0c0856d853117bde8413a4270d1d3487"{"foo": "bar", "baz": {"count": 42}, "__id__": "72dcf1ee-8efd-4d7f-8ca1-2eda2bf85099", "__updated__": "2012-05-09T20:33:36.928075+00:00"}
搜索商店:
$ curl -g 'http://127.0.0.1:31415/{"baz":{"count":"GreaterThan(40)"}}'[{"foo": "bar", "baz": {"count": 42}, "__id__": "72dcf1ee-8efd-4d7f-8ca1-2eda2bf85099", "__updated__": "2012-05-09T20:33:36.928075+00:00"}]
它还有一个python api。以上代码将按如下方式执行:
>>> fromjsonstore.clientimportEntryManager>>> fromjsonstore.operatorsimportGreaterThan>>> em=EntryManager('http://127.0.0.1:31415/')>>> em.create(foo="bar","baz"={"count":42})>>> results=em.search(baz={"count":GreaterThan(40)})
或者像这样,只是为了好玩:
>>> fromjsonstore.dslimportStore>>> store=Store('http://127.0.0.1:31415/')>>> {"foo":"bar","baz":{"count":42}}>>store>>> results=store|{"baz":{"count":GreaterThan(40)}}
请查看more examples的网站。