Skip to main content

A Python SDK for Apache HugeGraph

Project description

hugegraph-python

A Python SDK for Apache HugeGraph

Installation

pip3 install hugegraph-python

Install from source

release soon

Examples

from pyhugegraph.client import PyHugeClient

client = PyHugeClient("127.0.0.1", "8080", user="admin", pwd="admin", graph="hugegraph")

"""system"""
print(client.get_graphinfo())
print(client.get_all_graphs())
print(client.get_version())
print(client.get_graph_config())

"""schema"""
schema = client.schema()
schema.propertyKey("name").asText().ifNotExist().create()
schema.propertyKey("birthDate").asText().ifNotExist().create()
schema.vertexLabel("Person").properties("name", "birthDate").usePrimaryKeyId().primaryKeys(
    "name").ifNotExist().create()
schema.vertexLabel("Movie").properties("name").usePrimaryKeyId().primaryKeys(
    "name").ifNotExist().create()
schema.edgeLabel("ActedIn").sourceLabel("Person").targetLabel("Movie").ifNotExist().create()

print(schema.getVertexLabels())
print(schema.getEdgeLabels())
print(schema.getRelations())

"""graph"""
g = client.graph()
g.addVertex("Person", {"name": "Al Pacino", "birthDate": "1940-04-25"})
g.addVertex("Person", {"name": "Robert De Niro", "birthDate": "1943-08-17"})
g.addVertex("Movie", {"name": "The Godfather"})
g.addVertex("Movie", {"name": "The Godfather Part II"})
g.addVertex("Movie", {"name": "The Godfather Coda The Death of Michael Corleone"})

g.addEdge("ActedIn", "12:Al Pacino", "13:The Godfather", {})
g.addEdge("ActedIn", "12:Al Pacino", "13:The Godfather Part II", {})
g.addEdge("ActedIn", "12:Al Pacino", "13:The Godfather Coda The Death of Michael Corleone", {})
g.addEdge("ActedIn", "12:Robert De Niro", "13:The Godfather Part II", {})

res = g.getVertexById("12:Al Pacino").label
# g.removeVertexById("12:Al Pacino")
print(res)
g.close()

"""gremlin"""
g = client.gremlin()
res = g.exec("g.V().limit(10)")
print(res)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

hugegraph-python-1.3.0.tar.gz (20.8 kB view details)

Uploaded Source

Built Distribution

hugegraph_python-1.3.0-py3-none-any.whl (54.8 kB view details)

Uploaded Python 3

File details

Details for the file hugegraph-python-1.3.0.tar.gz.

File metadata

  • Download URL: hugegraph-python-1.3.0.tar.gz
  • Upload date:
  • Size: 20.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.9.6

File hashes

Hashes for hugegraph-python-1.3.0.tar.gz
Algorithm Hash digest
SHA256 fea80ae1106bd6f3541667275fa049a9b310cf0d990eca0eb9aad697a77a4868
MD5 ca079db7cddfcd8939f1e9856568bb70
BLAKE2b-256 9d74935d046456716bee7f16b30c4a5b31f58ba1f6c8deb936a6ef4ff7bf3354

See more details on using hashes here.

File details

Details for the file hugegraph_python-1.3.0-py3-none-any.whl.

File metadata

File hashes

Hashes for hugegraph_python-1.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e003d7285e503d235b84858b478a9d0108682b323b3dcfe01f309290d8f6dd58
MD5 71eadb3ad5198262f9443b28b7c4685d
BLAKE2b-256 fcd0e9071dc4382fc5c92a345d6993256387d5d044c2f6ff6b6fca64ceec31ab

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page