Skip to main content

poyonga

PyPI Version Build status

Python Groonga Client. poyonga support to HTTP and GQTP protocol.

Requrements

  • Python 3.6+

Installation

from pip:

pip install --upgrade poyonga

Usage

Setup Groonga Server

$ groonga -n grn.db     # create groonga database file
$ groonga -s grn.db     # start groonga server with GQTP

Basic Usage

>>> 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}
>>>

with eventlet

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()

Custom prefix path

If you use the Custom prefix path and Multi databases , specify prefix_path .

# default is '/d/'
g = Groonga(prefix_path='/db2/')

with Apache Arrow

Groonga supports Apache Arrow, use it with load and select commands.

use poyonga with Apache Arrow, you need pyarrow .

requrie pyarrow:

$ pip install pyarrow

and call with output_type="apache-arrow" option:

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",
)

load with 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")

more information:

example code

see examples directory

for Developer

install dev dependencies:

$ pip install ".[dev]"

run tests:

$ pytest

run linter:

$ ruff .

run formatter:

$ black --diff .

Release files for poyonga 0.6.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for poyonga 0.6.0
File Size Uploaded
poyonga-0.6.0.tar.gz 13.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for poyonga 0.6.0
File Interpreter ABI Platform
poyonga-0.6.0-py3-none-any.whl Python 3 none any Details

Total release size: 23.3 kB

Release files / poyonga-0.6.0.tar.gz

Download URL poyonga-0.6.0.tar.gz
Size 13.8 kB
Tags Source
SHA-256 checksum
How to use checksums
4da6c73cbd659297e6f6e88da5363cdf6962dcfc03cefa8fbc0b2627eceefa32
BLAKE2b-256 checksum
How to use checksums
dfaef9cadfc2bf00e973f9df45752eb17ded71665c3558fcb4599ff2e1de7226
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.6

Release files / poyonga-0.6.0-py3-none-any.whl

Download URL poyonga-0.6.0-py3-none-any.whl
Size 9.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
8abc4d57568b7aa41fe883f4257ec9f3ed55f1b39980b41f042fbd4bba7c847a
BLAKE2b-256 checksum
How to use checksums
6f30f0f667174eccaf28937347259f86ae06c6cfba9469267cbc61e8128f7f8a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.6

Release history Release notifications | RSS feed

This release

0.6.0 This release

2 release files

0.5.0

1 release file

0.4.1

1 release file

0.4.0

1 release file

0.3.1

1 release file

0.3

1 release file

0.2.4

1 release file

0.2.3

1 release file

0.2.2

1 release file

0.2.1

1 release file

0.2

1 release file

0.1.6

1 release file

0.1.5

1 release file

0.1.4

1 release file

0.1.3

1 release file

0.1.2

1 release file

0.1.1

1 release file

0.1

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page