Skip to content

Update graph.py #100

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions redisgraph/graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,13 @@ class Graph(object):
Graph, collection of nodes and edges.
"""

def __init__(self, name, redis_con):
def __init__(self, name, redis_con, read_only=False):
"""
Create a new graph.
"""
self.name = name # Graph key
self.redis_con = redis_con
self.read_only = read_only # Readonly Graph
self.nodes = {}
self.edges = []
self._labels = [] # List of node labels.
Expand Down Expand Up @@ -156,7 +157,7 @@ def query(self, q, params=None, timeout=None):
# construct query command
# ask for compact result-set format
# specify known graph version
command = ["GRAPH.QUERY", self.name, query, "--compact", "version", self.version]
command = ["GRAPH.RO_QUERY" if self.read_only else "GRAPH.QUERY", self.name, query, "--compact", "version", self.version]

# include timeout is specified
if timeout:
Expand Down