1
1
from .util import *
2
+ import redis
2
3
from .query_result import QueryResult
3
4
from .exceptions import VersionMismatchException
4
5
@@ -11,14 +12,14 @@ def __init__(self, name, redis_con):
11
12
"""
12
13
Create a new graph.
13
14
"""
14
- self .name = name # Graph key
15
- self .version = 0 # Graph version
15
+ self .name = name # Graph key
16
16
self .redis_con = redis_con
17
17
self .nodes = {}
18
18
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
22
23
23
24
def _clear_schema (self ):
24
25
self ._labels = []
@@ -154,7 +155,7 @@ def query(self, q, params=None, timeout=None):
154
155
155
156
# construct query command
156
157
# ask for compact result-set format
157
- # specify known version
158
+ # specify known graph version
158
159
command = ["GRAPH.QUERY" , self .name , query , "--compact" , "version" , self .version ]
159
160
160
161
# include timeout is specified
@@ -164,10 +165,13 @@ def query(self, q, params=None, timeout=None):
164
165
command += ["timeout" , timeout ]
165
166
166
167
# issue query
167
- response = self .redis_con .execute_command (* command )
168
-
169
168
try :
169
+ response = self .redis_con .execute_command (* command )
170
170
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
171
175
except VersionMismatchException as e :
172
176
# client view over the graph schema is out of sync
173
177
# set client version and refresh local schema
0 commit comments