Python Groonga客户
poyonga的Python项目详细描述
pythonGroonga客户端。 poyonga对http和gqtp协议的支持。
安装
来自PIP:
pip install --upgrade poyonga
从简易安装:
easy_install -ZU poyonga
用法
设置Groonga服务器
$ groonga -n grn.db # create groonga database file $ groonga -s grn.db # start groonga server with GQTP
基本用法
>>>frompoyongaimportGroonga>>>g=Groonga()>>>g.protocol'http'>>>ret=g.call("status")>>>ret<poyonga.result.GroongaResultobjectat0x8505ccc>>>>ret.status0>>>ret.body{u'uptime':427,u'max_command_version':2,u'n_queries':3,u'cache_hit_rate':66.6666666666667,u'version':u'1.2.8',u'alloc_count':156,u'command_version':1,u'starttime':1328286909,u'default_command_version':1}>>>
事件
frompoyongaimportGroongaimporteventleteventlet.monkey_patch()deffetch(cmd,**kwargs):g=Groonga()ret=g.call(cmd,**kwargs)printret.statusprintret.bodyprint"*"*40cmds=[("status",{}),("log_level",{"level":"warning"}),("table_list",{})("select",{"table":"Site"})]pool=eventlet.GreenPool()forcmd,kwargsincmds:pool.spawn_n(fetch,cmd,**kwargs)pool.waitall()
自定义前缀路径
如果使用Custom prefix path和Multi databases,请指定前缀路径。
# default is '/d/'g=Groonga(prefix_path='/db2/')