poyonga


Namepoyonga JSON
Version 0.6.0 PyPI version JSON
download
home_page
SummaryPython Groonga Client
upload_time2023-11-28 11:14:27
maintainer
docs_urlNone
author
requires_python>=3.8
licenseCopyright (c) 2012-2019 Hideo Hattori Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
keywords groonga http gqtp
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            =======
poyonga
=======

.. image:: https://img.shields.io/pypi/v/poyonga.svg
    :target: https://pypi.org/project/poyonga/
    :alt: PyPI Version

.. image:: https://github.com/hhatto/poyonga/workflows/Python%20package/badge.svg
    :target: https://github.com/hhatto/poyonga/actions
    :alt: Build status

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

.. _Groonga: http://groonga.org/


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

.. code-block:: python

    >>> 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
-------------
.. code-block:: python

    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` .

.. _`Custom prefix path`: http://groonga.org/docs/server/http/comparison.html#custom-prefix-path
.. _`Multi databases`: http://groonga.org/docs/server/http/comparison.html#multi-databases

.. code-block:: python

    # 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_ .

.. _`Apache Arrow`: https://arrow.apache.org/
.. _pyarrow: https://pypi.org/project/pyarrow/

requrie pyarrow::

    $ pip install pyarrow

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

.. code-block:: python

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

.. note:: `output_type` can also specify `poyonga.const.OutputType.APACHE_ARROW`.
    If is not specified, `poyonga.const.OutputType.JSON` is specified by default.

load with ``input_type="apache-arrow"``:

.. code-block:: python

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

.. note:: `input_type` can also specify `poyonga.const.InputType.APACHE_ARROW`.
    If is not specified, `poyonga.const.InputType.JSON` is specified by default.


more information:

- https://groonga.org/docs/reference/commands/load.html


example code
------------
see `examples directory`_

.. _`examples directory`: https://github.com/hhatto/poyonga/tree/master/examples


for Developer
=============

install dev dependencies::

    $ pip install ".[dev]"

run tests::

    $ pytest

run linter::

    $ ruff .


run formatter::

    $ black --diff .


Links
=====
* PyPI_
* GitHub_

.. _PyPI: https://pypi.python.org/pypi/poyonga
.. _GitHub: https://github.com/hhatto/poyonga

            

Raw data

            {
    "_id": null,
    "home_page": "",
    "name": "poyonga",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.8",
    "maintainer_email": "",
    "keywords": "groonga,http,gqtp",
    "author": "",
    "author_email": "Hideo Hattori <hhatto.jp@gmail.com>",
    "download_url": "https://files.pythonhosted.org/packages/df/ae/f9cadfc2bf00e973f9df45752eb17ded71665c3558fcb4599ff2e1de7226/poyonga-0.6.0.tar.gz",
    "platform": null,
    "description": "=======\npoyonga\n=======\n\n.. image:: https://img.shields.io/pypi/v/poyonga.svg\n    :target: https://pypi.org/project/poyonga/\n    :alt: PyPI Version\n\n.. image:: https://github.com/hhatto/poyonga/workflows/Python%20package/badge.svg\n    :target: https://github.com/hhatto/poyonga/actions\n    :alt: Build status\n\nPython Groonga_ Client.\npoyonga support to HTTP and GQTP protocol.\n\n.. _Groonga: http://groonga.org/\n\n\nRequrements\n===========\n* Python 3.6+\n\n\nInstallation\n============\nfrom pip::\n\n    pip install --upgrade poyonga\n\n\nUsage\n=====\n\nSetup Groonga Server\n--------------------\n::\n\n    $ groonga -n grn.db     # create groonga database file\n    $ groonga -s grn.db     # start groonga server with GQTP\n\n\nBasic Usage\n-----------\n\n.. code-block:: python\n\n    >>> from poyonga import Groonga\n    >>> g = Groonga()\n    >>> g.protocol\n    'http'\n    >>> ret = g.call(\"status\")\n    >>> ret\n    <poyonga.result.GroongaResult object at 0x8505ccc>\n    >>> ret.status\n    0\n    >>> ret.body\n    {u'uptime': 427, u'max_command_version': 2, u'n_queries': 3,\n    u'cache_hit_rate': 66.6666666666667, u'version': u'1.2.8', u\n    'alloc_count': 156, u'command_version': 1, u'starttime': 132\n    8286909, u'default_command_version': 1}\n    >>>\n\nwith eventlet\n-------------\n.. code-block:: python\n\n    from poyonga import Groonga\n    import eventlet\n\n    eventlet.monkey_patch()\n\n    def fetch(cmd, **kwargs):\n        g = Groonga()\n        ret = g.call(cmd, **kwargs)\n        print ret.status\n        print ret.body\n        print \"*\" * 40\n\n    cmds = [(\"status\", {}),\n            (\"log_level\", {\"level\": \"warning\"}),\n            (\"table_list\", {})\n            (\"select\", {\"table\": \"Site\"})]\n    pool = eventlet.GreenPool()\n    for cmd, kwargs in cmds:\n        pool.spawn_n(fetch, cmd, **kwargs)\n    pool.waitall()\n\nCustom prefix path\n------------------\nIf you use the `Custom prefix path`_ and `Multi databases`_ , specify `prefix_path` .\n\n.. _`Custom prefix path`: http://groonga.org/docs/server/http/comparison.html#custom-prefix-path\n.. _`Multi databases`: http://groonga.org/docs/server/http/comparison.html#multi-databases\n\n.. code-block:: python\n\n    # default is '/d/'\n    g = Groonga(prefix_path='/db2/')\n\nwith Apache Arrow\n-----------------\nGroonga supports `Apache Arrow`_, use it with ``load`` and ``select`` commands.\n\nuse poyonga with Apache Arrow, you need pyarrow_ .\n\n.. _`Apache Arrow`: https://arrow.apache.org/\n.. _pyarrow: https://pypi.org/project/pyarrow/\n\nrequrie pyarrow::\n\n    $ pip install pyarrow\n\nand call with ``output_type=\"apache-arrow\"`` option:\n\n.. code-block:: python\n\n    from poyonga import Groonga\n\n    g = Groonga()\n    g.call(\n        \"select\",\n        table=\"Users\",\n        match_columns=\"name,location_str,description\",\n        query=\"\u6771\u4eac\",\n        output_type=\"apache-arrow\",\n        output_columns=\"_key,name\",\n    )\n\n.. note:: `output_type` can also specify `poyonga.const.OutputType.APACHE_ARROW`.\n    If is not specified, `poyonga.const.OutputType.JSON` is specified by default.\n\nload with ``input_type=\"apache-arrow\"``:\n\n.. code-block:: python\n\n    import pyarrow as pa\n    from poyonga import Groonga\n\n    # use Apache Arrow IPC Streaming Format\n    data = [pa.array([\"groonga.org\"])]\n    batch = pa.record_batch(data, names=[\"_key\"])\n    sink = pa.BufferOutputStream()\n    with pa.ipc.new_stream(sink, batch.schema) as writer:\n        writer.write_batch(batch)\n    buf = sink.getvalue()\n    values = buf.to_pybytes()\n\n    g = Groonga()\n    g.call(\"load\", table=\"Site\", values=values, input_type=\"apache-arrow\")\n\n.. note:: `input_type` can also specify `poyonga.const.InputType.APACHE_ARROW`.\n    If is not specified, `poyonga.const.InputType.JSON` is specified by default.\n\n\nmore information:\n\n- https://groonga.org/docs/reference/commands/load.html\n\n\nexample code\n------------\nsee `examples directory`_\n\n.. _`examples directory`: https://github.com/hhatto/poyonga/tree/master/examples\n\n\nfor Developer\n=============\n\ninstall dev dependencies::\n\n    $ pip install \".[dev]\"\n\nrun tests::\n\n    $ pytest\n\nrun linter::\n\n    $ ruff .\n\n\nrun formatter::\n\n    $ black --diff .\n\n\nLinks\n=====\n* PyPI_\n* GitHub_\n\n.. _PyPI: https://pypi.python.org/pypi/poyonga\n.. _GitHub: https://github.com/hhatto/poyonga\n",
    "bugtrack_url": null,
    "license": "Copyright (c) 2012-2019 Hideo Hattori  Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:  The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ",
    "summary": "Python Groonga Client",
    "version": "0.6.0",
    "project_urls": {
        "Repository": "https://github.com/hhatto/poyonga"
    },
    "split_keywords": [
        "groonga",
        "http",
        "gqtp"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "6f30f0f667174eccaf28937347259f86ae06c6cfba9469267cbc61e8128f7f8a",
                "md5": "2f35f520b1c82dd74d1301affc17e206",
                "sha256": "8abc4d57568b7aa41fe883f4257ec9f3ed55f1b39980b41f042fbd4bba7c847a"
            },
            "downloads": -1,
            "filename": "poyonga-0.6.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "2f35f520b1c82dd74d1301affc17e206",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8",
            "size": 9547,
            "upload_time": "2023-11-28T11:14:25",
            "upload_time_iso_8601": "2023-11-28T11:14:25.528287Z",
            "url": "https://files.pythonhosted.org/packages/6f/30/f0f667174eccaf28937347259f86ae06c6cfba9469267cbc61e8128f7f8a/poyonga-0.6.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "dfaef9cadfc2bf00e973f9df45752eb17ded71665c3558fcb4599ff2e1de7226",
                "md5": "000379d23a99772fd0241a4e570f9585",
                "sha256": "4da6c73cbd659297e6f6e88da5363cdf6962dcfc03cefa8fbc0b2627eceefa32"
            },
            "downloads": -1,
            "filename": "poyonga-0.6.0.tar.gz",
            "has_sig": false,
            "md5_digest": "000379d23a99772fd0241a4e570f9585",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8",
            "size": 13754,
            "upload_time": "2023-11-28T11:14:27",
            "upload_time_iso_8601": "2023-11-28T11:14:27.451596Z",
            "url": "https://files.pythonhosted.org/packages/df/ae/f9cadfc2bf00e973f9df45752eb17ded71665c3558fcb4599ff2e1de7226/poyonga-0.6.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-11-28 11:14:27",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "hhatto",
    "github_project": "poyonga",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "tox": true,
    "lcname": "poyonga"
}
        
Elapsed time: 0.17688s