几乎是postgres hstore解析器。
cpghstore的Python项目详细描述
Info: | cpghstore is a fast decoder/encoder of the PostgreSQL hstore data type (http://www.postgresql.org/docs/9.0/static/hstore.html). |
---|---|
Author: | Robert Kajic (http://github.com/kajic) |
关于
cpghstore是用c编写的,它是 pghstore。运行python setup.py test -s benchmark查看它的执行情况(如果 您希望显示比较)。
安装
运行pip install cpghstore或下载 从GitHub中获取源并运行python setup.py install。
用法
解码和编码hstore字符串:
>>> import cpghstore >>> # decode >>> d = cpghstore.loads('"name"=>"Norge/Noreg"') >>> d {'name': 'Norge/Noreg'} >>> # encode >>> s = cpghstore.dumps(d) >>> s '"name"=>"Norge/Noreg"'
测试
要运行测试套件,请运行python setup.py test。
基准
运行python setup.py test -s benchmark查看它的性能(需要 如果要显示比较,请安装pghstore)。
限制
只支持str字符串(即不支持unicode字符串)。 只能解码(加载)字符串值,即在 “key”=>;123不是。