poyonga
Version 0.6.0

Python Groonga 클라이언트. HTTP 및 GQTP 프로토콜을 지원합니다.
PIP에서 :
PIP 설치 -업그레이드 포야 옹가
$ groonga -n grn.db # Groonga 데이터베이스 파일 생성 $ groonga -s grn.db # gqtp로 Groonga Server 시작
> >> from poyonga import Groonga
> >> g = Groonga ()
> >> g . protocol
'http'
> >> ret = g . call ( "status" )
> >> ret
< poyonga . result . GroongaResult object at 0x8505ccc >
> >> ret . status
0
> >> 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' : 132
8286909 , u'default_command_version' : 1 }
> >> from poyonga import Groonga
import eventlet
eventlet . monkey_patch ()
def fetch ( cmd , ** kwargs ):
g = Groonga ()
ret = g . call ( cmd , ** kwargs )
print ret . status
print ret . body
print "*" * 40
cmds = [( "status" , {}),
( "log_level" , { "level" : "warning" }),
( "table_list" , {})
( "select" , { "table" : "Site" })]
pool = eventlet . GreenPool ()
for cmd , kwargs in cmds :
pool . spawn_n ( fetch , cmd , ** kwargs )
pool . waitall ()사용자 정의 접두사 경로 및 다중 데이터베이스를 사용하는 경우 Prefix_path를 지정하십시오.
# default is '/d/'
g = Groonga ( prefix_path = '/db2/' ) Groonga는 Apache Arrow를 지원하고 load 및 select 명령으로 사용합니다.
Apache Arrow와 함께 Poyonga를 사용하면 Pyarrow가 필요합니다.
requrie pyarrow :
$ PIP 설치 Pyarrow
output_type="apache-arrow" 옵션으로 호출하십시오.
from poyonga import Groonga
g = Groonga ()
g . call (
"select" ,
table = "Users" ,
match_columns = "name,location_str,description" ,
query = "東京" ,
output_type = "apache-arrow" ,
output_columns = "_key,name" ,
)메모
output_type는 또한 poyonga.const.outputtype.apache_arrow를 지정할 수도 있습니다. 지정되지 않은 경우, poyonga.const.outputtype.json은 기본적으로 지정됩니다.
input_type="apache-arrow" 로로드 : :
import pyarrow as pa
from poyonga import Groonga
# use Apache Arrow IPC Streaming Format
data = [ pa . array ([ "groonga.org" ])]
batch = pa . record_batch ( data , names = [ "_key" ])
sink = pa . BufferOutputStream ()
with pa . ipc . new_stream ( sink , batch . schema ) as writer :
writer . write_batch ( batch )
buf = sink . getvalue ()
values = buf . to_pybytes ()
g = Groonga ()
g . call ( "load" , table = "Site" , values = values , input_type = "apache-arrow" )메모
input_type는 또한 poyonga.const.inputtype.apache_arrow를 지정할 수도 있습니다. 지정되지 않은 경우, poyonga.const.inputtype.json은 기본적으로 지정됩니다.
추가 정보 :
예제 디렉토리를 참조하십시오
DEV 의존성 설치 :
$ pip install ". [dev]"
실행 테스트 :
$ pytest
런 라이터 :
$ ruff.
Formatter 실행 :
$ black -diff.