Skip to content

Commit 535524f

Browse files
committed
print require version on arity exception
1 parent 10c69cb commit 535524f

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

redisgraph/graph.py

+12-8
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
from .util import *
2+
import redis
23
from .query_result import QueryResult
34
from .exceptions import VersionMismatchException
45

@@ -11,14 +12,14 @@ def __init__(self, name, redis_con):
1112
"""
1213
Create a new graph.
1314
"""
14-
self.name = name # Graph key
15-
self.version = 0 # Graph version
15+
self.name = name # Graph key
1616
self.redis_con = redis_con
1717
self.nodes = {}
1818
self.edges = []
19-
self._labels = [] # List of node labels.
20-
self._properties = [] # List of properties.
21-
self._relationshipTypes = [] # List of relation types.
19+
self._labels = [] # List of node labels.
20+
self._properties = [] # List of properties.
21+
self._relationshipTypes = [] # List of relation types.
22+
self.version = 0 # Graph version
2223

2324
def _clear_schema(self):
2425
self._labels = []
@@ -154,7 +155,7 @@ def query(self, q, params=None, timeout=None):
154155

155156
# construct query command
156157
# ask for compact result-set format
157-
# specify known version
158+
# specify known graph version
158159
command = ["GRAPH.QUERY", self.name, query, "--compact", "version", self.version]
159160

160161
# include timeout is specified
@@ -164,10 +165,13 @@ def query(self, q, params=None, timeout=None):
164165
command += ["timeout", timeout]
165166

166167
# issue query
167-
response = self.redis_con.execute_command(*command)
168-
169168
try:
169+
response = self.redis_con.execute_command(*command)
170170
return QueryResult(self, response)
171+
except redis.exceptions.ResponseError as e:
172+
if "wrong number of arguments" in str(e):
173+
print ("Note: RedisGraph Python requires server version 2.2.8 or above")
174+
raise e
171175
except VersionMismatchException as e:
172176
# client view over the graph schema is out of sync
173177
# set client version and refresh local schema

0 commit comments

Comments
 (0)