From 060bbdda77e37d7a1ef86cb9b802a7e5e4df516b Mon Sep 17 00:00:00 2001 From: Gnanesh Date: Thu, 6 May 2021 13:12:18 +0530 Subject: [PATCH 1/2] `GRAPH.RO_QUERY` is unavailable in older versions. So fallback to GRAPH.QUERY when the command is not found. --- redisgraph/graph.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/redisgraph/graph.py b/redisgraph/graph.py index f4d802f..c333036 100644 --- a/redisgraph/graph.py +++ b/redisgraph/graph.py @@ -177,6 +177,11 @@ def query(self, q, params=None, timeout=None, read_only=False): except redis.exceptions.ResponseError as e: if "wrong number of arguments" in str(e): print("Note: RedisGraph Python requires server version 2.2.8 or above") + if "unknown command" in str(e): + # `GRAPH.RO_QUERY` is unavailable in older versions. + command[0] = "GRAPH.QUERY" + response = self.redis_con.execute_command(*command) + return QueryResult(self, response) raise e except VersionMismatchException as e: # client view over the graph schema is out of sync From f57ceb4c8b526de04a4d88b105a6d44d8ac6d7bb Mon Sep 17 00:00:00 2001 From: Gnanesh Date: Thu, 6 May 2021 16:29:00 +0530 Subject: [PATCH 2/2] Call the same method by setting read_only to `False` --- redisgraph/graph.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/redisgraph/graph.py b/redisgraph/graph.py index c333036..7653645 100644 --- a/redisgraph/graph.py +++ b/redisgraph/graph.py @@ -177,11 +177,9 @@ def query(self, q, params=None, timeout=None, read_only=False): except redis.exceptions.ResponseError as e: if "wrong number of arguments" in str(e): print("Note: RedisGraph Python requires server version 2.2.8 or above") - if "unknown command" in str(e): + if "unknown command" in str(e) and read_only: # `GRAPH.RO_QUERY` is unavailable in older versions. - command[0] = "GRAPH.QUERY" - response = self.redis_con.execute_command(*command) - return QueryResult(self, response) + return self.query(q, params, timeout, read_only=False) raise e except VersionMismatchException as e: # client view over the graph schema is out of sync