A Python SDK for Apache HugeGraph
Project description
hugegraph-python
A Python SDK for Apache HugeGraph, maintained by cvte research data-mining team.
This project currently in alpha testing, will open source the code soon.
Installation
PyPi
https://pypi.org/project/hugegraph-python/
pip3 install hugegraph-python
Install from source
release soon
Examples
from hugegraph.connection import PyHugeGraph
client = PyHugeGraph("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)
Any questions contact ming@apache.org
- TODO
- document
- ut
- ci
- more api
Project details
Release history Release notifications | RSS feed
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.0.0.12.tar.gz
(16.2 kB
view hashes)
Built Distribution
Close
Hashes for hugegraph-python-1.0.0.12.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 06b2dded70c4f4570083f8b6e3a9edfebcf5ac4f07300727afad72389917ab85 |
|
MD5 | 97284605cfaea0fccea63be2e430abc3 |
|
BLAKE2b-256 | 8582b92e31474dccf771551bf98ad88977e330f00424de013ad53d7bbbd2d58a |
Close
Hashes for hugegraph_python-1.0.0.12-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 69fe20edbe1a392d16afc74df5c94b3b96bc02c848e9ab5b5f18c112a9bc3ebe |
|
MD5 | 9250ce6bb5fbd01ec6a7337c5824a82f |
|
BLAKE2b-256 | 8273adb0a5041f1231a3c1564bc38d0317af8dfc667b634b093152cd2813743a |