Skip to content

Commit 4315e98

Browse files
committed
redisgraph response can contain only statistics
1 parent d676237 commit 4315e98

File tree

3 files changed

+18
-10
lines changed

3 files changed

+18
-10
lines changed

redisgraph/client.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -129,10 +129,17 @@ def query(self, q):
129129
"""
130130
Executes a query against the graph.
131131
"""
132+
statistics = None
133+
result_set = None
132134
response = self.redis_con.execute_command("GRAPH.QUERY", self.name, q)
133-
data = response[0]
134-
statistics = response[1]
135-
result_set = [res.decode().split(',') for res in data]
135+
136+
if len(response) == 1:
137+
statistics = response[0]
138+
else:
139+
data = response[0]
140+
statistics = response[1]
141+
result_set = [res.decode().split(',') for res in data]
142+
136143
return QueryResult(result_set, statistics)
137144

138145
def execution_plan(self, query):

redisgraph/query_result.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,15 @@ def __init__(self, result_set, statistics):
2222
3. Prints the statistics of the query.
2323
"""
2424
def pretty_print(self):
25-
tbl = PrettyTable(self.result_set[0])
26-
for row in self.result_set[1:]:
27-
tbl.add_row(row)
25+
if self.result_set is not None:
26+
tbl = PrettyTable(self.result_set[0])
27+
for row in self.result_set[1:]:
28+
tbl.add_row(row)
2829

29-
if len(self.result_set) == 1:
30-
tbl.add_row(['No data returned.'])
30+
if len(self.result_set) == 1:
31+
tbl.add_row(['No data returned.'])
3132

32-
print(str(tbl) + '\n')
33+
print(str(tbl) + '\n')
3334

3435
for stat in self.statistics:
3536
print(stat)

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from setuptools import setup, find_packages
22
setup(
33
name='redisgraph',
4-
version='0.9',
4+
version='1.0',
55

66
description='RedisGraph Python Client',
77
url='https://github.com/swilly22/redisgraph-py',

0 commit comments

Comments
 (0)