Skip to main content

RedisGraph Python Client

Project description

license CircleCI PyPI version GitHub issues

redisgraph-py

RedisGraph python client

Example: Using the Python Client

import redis
from redisgraph import Node, Edge, Graph

r = redis.Redis(host='localhost', port=6379)

redis_graph = Graph('social', r)

john = Node(label='person', properties={'name': 'John Doe', 'age': 33, 'gender': 'male', 'status': 'single'})
redis_graph.add_node(john)

japan = Node(label='country', properties={'name': 'Japan'})
redis_graph.add_node(japan)

edge = Edge(john, 'visited', japan, properties={'purpose': 'pleasure'})
redis_graph.add_edge(edge)

redis_graph.commit()

query = """MATCH (p:person)-[v:visited {purpose:"pleasure"}]->(c:country)
		   RETURN p.name, p.age, v.purpose, c.name"""

result = redis_graph.query(query)

# Print resultset
result.pretty_print()

# Iterate through resultset, skip header row at position 0
for record in result.result_set[1:]:
	person_name = record[0]
	person_age = record[1]
	visit_purpose = record[2]
	country_name = record[3]


# All done, remove graph.
redis_graph.delete()

Installing

pip install redisgraph

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

redisgraph-2.1.tar.gz (5.8 kB view details)

Uploaded Source

File details

Details for the file redisgraph-2.1.tar.gz.

File metadata

  • Download URL: redisgraph-2.1.tar.gz
  • Upload date:
  • Size: 5.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.6.3 requests-toolbelt/0.9.1 tqdm/4.32.1 CPython/2.7.17

File hashes

Hashes for redisgraph-2.1.tar.gz
Algorithm Hash digest
SHA256 66fce47e165ae54e3adafb211de9e6f2ffc46adbb8a8c354fc58fb87603c9d54
MD5 a3fbcd4957bd490e80242452ecbb5f3e
BLAKE2b-256 4c6136190ac30f1d2e7226942f8c90270eb8bac368dbfa1b085130b876686e64

See more details on using hashes here.

Supported by

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