gremlinpython


Namegremlinpython JSON
Version 3.7.2 PyPI version JSON
download
home_pagehttp://tinkerpop.apache.org
SummaryGremlin-Python for Apache TinkerPop
upload_time2024-04-15 17:17:49
maintainerNone
docs_urlNone
authorNone
requires_pythonNone
licenseApache 2
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            .. Licensed to the Apache Software Foundation (ASF) under one
.. or more contributor license agreements.  See the NOTICE file
.. distributed with this work for additional information
.. regarding copyright ownership.  The ASF licenses this file
.. to you under the Apache License, Version 2.0 (the
.. "License"); you may not use this file except in compliance
.. with the License.  You may obtain a copy of the License at
..
..  http://www.apache.org/licenses/LICENSE-2.0
..
.. Unless required by applicable law or agreed to in writing,
.. software distributed under the License is distributed on an
.. "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
.. KIND, either express or implied.  See the License for the
.. specific language governing permissions and limitations
.. under the License.

=================================
Apache TinkerPop - Gremlin Python
=================================

`Apache TinkerPop™ <https://tinkerpop.apache.org>`_
is a graph computing framework for both graph databases (OLTP) and
graph analytic systems (OLAP). `Gremlin <https://tinkerpop.apache.org/gremlin.html>`_
is the graph traversal language of
TinkerPop. It can be described as a functional, data-flow language that enables users to succinctly express complex
traversals on (or queries of) their application's property graph.

Gremlin-Python implements Gremlin within the Python language and can be used on any Python virtual machine including
the popular CPython machine. Python’s syntax has the same constructs as Java including "dot notation" for function
chaining ``(a.b.c)``, round bracket function arguments ``(a(b,c))``, and support for global namespaces
``(a(b()) vs a(__.b()))``. As such, anyone familiar with Gremlin-Java will immediately be able to work with
Gremlin-Python. Moreover, there are a few added constructs to Gremlin-Python that make traversals a bit more succinct.

Gremlin-Python is designed to connect to a "server" that is hosting a TinkerPop-enabled graph system. That "server"
could be `Gremlin Server <https://tinkerpop.apache.org/docs/current/reference/#gremlin-server>`_ or a
`remote Gremlin provider <https://tinkerpop.apache.org/docs/current/reference/#connecting-rgp>`_ that exposes
protocols by which Gremlin-Python can connect.

A typical connection to a server running on "localhost" that supports the Gremlin Server protocol using websockets
from the Python shell looks like this:

    >>> from gremlin_python.process.anonymous_traversal import traversal
    >>> from gremlin_python.driver.driver_remote_connection import DriverRemoteConnection
    >>> g = traversal().with_remote(DriverRemoteConnection('ws://localhost:8182/gremlin','g'))

Once "g" has been created using a connection, it is then possible to start writing Gremlin traversals to query the
remote graph:

    >>> g.V().both()[1:3].to_list()
    [v[2], v[4]]
    >>> g.V().both()[1].to_list()
    [v[2]]
    >>> g.V().both().name.to_list()
    [lop, vadas, josh, marko, marko, josh, peter, ripple, lop, marko, josh, lop]

-----------------
Sample Traversals
-----------------

The Gremlin language allows users to write highly expressive graph traversals and has a broad list of functions that
cover a wide body of features. The `Reference Documentation <https://tinkerpop.apache.org/docs/current/reference/#graph-traversal-steps>`_
describes these functions and other aspects of the TinkerPop ecosystem including some specifics on
`Gremlin in Python <https://tinkerpop.apache.org/docs/current/reference/#gremlin-python>`_ itself. Most of the
examples found in the documentation use Groovy language syntax in the
`Gremlin Console <https://tinkerpop.apache.org/docs/current/tutorials/the-gremlin-console/>`_.
For the most part, these examples should generally translate to Python with
`some modification <https://tinkerpop.apache.org/docs/current/reference/#gremlin-python-differences>`_. Given the
strong correspondence between canonical Gremlin in Java and its variants like Python, there is a limited amount of
Python-specific documentation and examples. This strong correspondence among variants ensures that the general
Gremlin reference documentation is applicable to all variants and that users moving between development languages can
easily adopt the Gremlin variant for that language.

Create Vertex
^^^^^^^^^^^^^

.. code:: python

    from gremlin_python.process.traversal import T
    from gremlin_python.process.traversal import Cardinality

    id = T.id
    single = Cardinality.single

    def create_vertex(self, vid, vlabel):
        # default database cardinality is used when Cardinality argument is not specified
        g.add_v(vlabel).property(id, vid). \
          property(single, 'name', 'Apache'). \
          property('lastname', 'Tinkerpop'). \
          next()

Find Vertices
^^^^^^^^^^^^^

.. code:: python

    def list_all(self, limit=500):
        g.V().limit(limit).element_map().to_list()

    def find_vertex(self, vid):
        g.V(vid).element_map().next()

    def list_by_label_name(self, vlabel, name):
        g.V().has(vlabel, 'name', name).element_map().to_list()

Update Vertex
^^^^^^^^^^^^^

.. code:: python

    from gremlin_python.process.traversal import Cardinality

    single = Cardinality.single

    def update_vertex(self, vid, name):
        g.V(vid).property(single, 'name', name).next()

NOTE that versions suffixed with "rc" are considered release candidates (i.e. pre-alpha, alpha, beta, etc.) and
thus for early testing purposes only. These releases are not suitable for production.


            

Raw data

            {
    "_id": null,
    "home_page": "http://tinkerpop.apache.org",
    "name": "gremlinpython",
    "maintainer": null,
    "docs_url": null,
    "requires_python": null,
    "maintainer_email": null,
    "keywords": null,
    "author": null,
    "author_email": null,
    "download_url": "https://files.pythonhosted.org/packages/c9/3f/798d17661a13d2da2721038e2c3602c33225b482da76a6bf2cbe23a034d7/gremlinpython-3.7.2.tar.gz",
    "platform": null,
    "description": ".. Licensed to the Apache Software Foundation (ASF) under one\n.. or more contributor license agreements.  See the NOTICE file\n.. distributed with this work for additional information\n.. regarding copyright ownership.  The ASF licenses this file\n.. to you under the Apache License, Version 2.0 (the\n.. \"License\"); you may not use this file except in compliance\n.. with the License.  You may obtain a copy of the License at\n..\n..  http://www.apache.org/licenses/LICENSE-2.0\n..\n.. Unless required by applicable law or agreed to in writing,\n.. software distributed under the License is distributed on an\n.. \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\n.. KIND, either express or implied.  See the License for the\n.. specific language governing permissions and limitations\n.. under the License.\n\n=================================\nApache TinkerPop - Gremlin Python\n=================================\n\n`Apache TinkerPop\u2122 <https://tinkerpop.apache.org>`_\nis a graph computing framework for both graph databases (OLTP) and\ngraph analytic systems (OLAP). `Gremlin <https://tinkerpop.apache.org/gremlin.html>`_\nis the graph traversal language of\nTinkerPop. It can be described as a functional, data-flow language that enables users to succinctly express complex\ntraversals on (or queries of) their application's property graph.\n\nGremlin-Python implements Gremlin within the Python language and can be used on any Python virtual machine including\nthe popular CPython machine. Python\u2019s syntax has the same constructs as Java including \"dot notation\" for function\nchaining ``(a.b.c)``, round bracket function arguments ``(a(b,c))``, and support for global namespaces\n``(a(b()) vs a(__.b()))``. As such, anyone familiar with Gremlin-Java will immediately be able to work with\nGremlin-Python. Moreover, there are a few added constructs to Gremlin-Python that make traversals a bit more succinct.\n\nGremlin-Python is designed to connect to a \"server\" that is hosting a TinkerPop-enabled graph system. That \"server\"\ncould be `Gremlin Server <https://tinkerpop.apache.org/docs/current/reference/#gremlin-server>`_ or a\n`remote Gremlin provider <https://tinkerpop.apache.org/docs/current/reference/#connecting-rgp>`_ that exposes\nprotocols by which Gremlin-Python can connect.\n\nA typical connection to a server running on \"localhost\" that supports the Gremlin Server protocol using websockets\nfrom the Python shell looks like this:\n\n    >>> from gremlin_python.process.anonymous_traversal import traversal\n    >>> from gremlin_python.driver.driver_remote_connection import DriverRemoteConnection\n    >>> g = traversal().with_remote(DriverRemoteConnection('ws://localhost:8182/gremlin','g'))\n\nOnce \"g\" has been created using a connection, it is then possible to start writing Gremlin traversals to query the\nremote graph:\n\n    >>> g.V().both()[1:3].to_list()\n    [v[2], v[4]]\n    >>> g.V().both()[1].to_list()\n    [v[2]]\n    >>> g.V().both().name.to_list()\n    [lop, vadas, josh, marko, marko, josh, peter, ripple, lop, marko, josh, lop]\n\n-----------------\nSample Traversals\n-----------------\n\nThe Gremlin language allows users to write highly expressive graph traversals and has a broad list of functions that\ncover a wide body of features. The `Reference Documentation <https://tinkerpop.apache.org/docs/current/reference/#graph-traversal-steps>`_\ndescribes these functions and other aspects of the TinkerPop ecosystem including some specifics on\n`Gremlin in Python <https://tinkerpop.apache.org/docs/current/reference/#gremlin-python>`_ itself. Most of the\nexamples found in the documentation use Groovy language syntax in the\n`Gremlin Console <https://tinkerpop.apache.org/docs/current/tutorials/the-gremlin-console/>`_.\nFor the most part, these examples should generally translate to Python with\n`some modification <https://tinkerpop.apache.org/docs/current/reference/#gremlin-python-differences>`_. Given the\nstrong correspondence between canonical Gremlin in Java and its variants like Python, there is a limited amount of\nPython-specific documentation and examples. This strong correspondence among variants ensures that the general\nGremlin reference documentation is applicable to all variants and that users moving between development languages can\neasily adopt the Gremlin variant for that language.\n\nCreate Vertex\n^^^^^^^^^^^^^\n\n.. code:: python\n\n    from gremlin_python.process.traversal import T\n    from gremlin_python.process.traversal import Cardinality\n\n    id = T.id\n    single = Cardinality.single\n\n    def create_vertex(self, vid, vlabel):\n        # default database cardinality is used when Cardinality argument is not specified\n        g.add_v(vlabel).property(id, vid). \\\n          property(single, 'name', 'Apache'). \\\n          property('lastname', 'Tinkerpop'). \\\n          next()\n\nFind Vertices\n^^^^^^^^^^^^^\n\n.. code:: python\n\n    def list_all(self, limit=500):\n        g.V().limit(limit).element_map().to_list()\n\n    def find_vertex(self, vid):\n        g.V(vid).element_map().next()\n\n    def list_by_label_name(self, vlabel, name):\n        g.V().has(vlabel, 'name', name).element_map().to_list()\n\nUpdate Vertex\n^^^^^^^^^^^^^\n\n.. code:: python\n\n    from gremlin_python.process.traversal import Cardinality\n\n    single = Cardinality.single\n\n    def update_vertex(self, vid, name):\n        g.V(vid).property(single, 'name', name).next()\n\nNOTE that versions suffixed with \"rc\" are considered release candidates (i.e. pre-alpha, alpha, beta, etc.) and\nthus for early testing purposes only. These releases are not suitable for production.\n\n",
    "bugtrack_url": null,
    "license": "Apache 2",
    "summary": "Gremlin-Python for Apache TinkerPop",
    "version": "3.7.2",
    "project_urls": {
        "Homepage": "http://tinkerpop.apache.org"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "2035f70c50cf76419ed2f16d66d1362043796580ff357c2664eca7c023f8ca2d",
                "md5": "fe49b4c492ad64a92739dccb6f40ccbe",
                "sha256": "ff925632f70fc5afff6864627fa69de8df577090a6eea63f10f0fed7194f98bf"
            },
            "downloads": -1,
            "filename": "gremlinpython-3.7.2-py2.py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "fe49b4c492ad64a92739dccb6f40ccbe",
            "packagetype": "bdist_wheel",
            "python_version": "py2.py3",
            "requires_python": null,
            "size": 78094,
            "upload_time": "2024-04-15T17:17:46",
            "upload_time_iso_8601": "2024-04-15T17:17:46.591548Z",
            "url": "https://files.pythonhosted.org/packages/20/35/f70c50cf76419ed2f16d66d1362043796580ff357c2664eca7c023f8ca2d/gremlinpython-3.7.2-py2.py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "c93f798d17661a13d2da2721038e2c3602c33225b482da76a6bf2cbe23a034d7",
                "md5": "23d4c831023b9e4ebe47d52d12209eb5",
                "sha256": "58d12e4af81210d7770d54da8f1f586de816bc00858e095f76326d338ea34acd"
            },
            "downloads": -1,
            "filename": "gremlinpython-3.7.2.tar.gz",
            "has_sig": false,
            "md5_digest": "23d4c831023b9e4ebe47d52d12209eb5",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 52153,
            "upload_time": "2024-04-15T17:17:49",
            "upload_time_iso_8601": "2024-04-15T17:17:49.214518Z",
            "url": "https://files.pythonhosted.org/packages/c9/3f/798d17661a13d2da2721038e2c3602c33225b482da76a6bf2cbe23a034d7/gremlinpython-3.7.2.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-04-15 17:17:49",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "lcname": "gremlinpython"
}
        
Elapsed time: 0.25501s