RedisGraph / redisgraph-py

RedisGraph python client
https://redisgraph.io
BSD 3-Clause "New" or "Revised" License
189 stars 49 forks source link

IndexError: redis_graph.commit() #40

Closed andreaBelmont closed 5 years ago

andreaBelmont commented 5 years ago

Running this code

import redis
import redisgraph
print(redis.__version__)
from redisgraph import Node, Edge, Graph
r = redis.Redis(host='localhost', port=6379)
redis_graph = Graph('social', r)
john = Node(label='person', properties={'name': 'John Doe', 'age': 33, 'gender': 'male', 'status': 'single'})
redis_graph.add_node(john)
japan = Node(label='country', properties={'name': 'Japan'})
redis_graph.add_node(japan)
redis_graph.commit()

raises:

3.2.1
Traceback (most recent call last):
  File "./test.py", line 11, in <module>
    redis_graph.commit()
  File "/Users/acortis/my_codes/testbed/redisgraph/.env/lib/python3.7/site-packages/redisgraph/client.py", line 136, in commit
    return self.query(query)
  File "/Users/acortis/my_codes/testbed/redisgraph/.env/lib/python3.7/site-packages/redisgraph/client.py", line 158, in query
    statistics = response[1]
IndexError: list index out of range

redis-cli monitor shows

redis-cli monitor
OK

1560173120.370804 [0 [::1]:58173] "GRAPH.QUERY" "social" "CREATE (rhevungnwv:person{name:\"John Doe\",age:33,gender:\"male\",status:\"single\"}),(wtqgmdvmfi:country{name:\"Japan\"})"

The redisgraph.so library was built successfully from commit:

commit 728080f8d6bf72dc12fd90a98f741dbb0f04b74b (HEAD -> master, origin/master, origin/HEAD)

Could you please help?

Thanks

Andrea

swilly22 commented 5 years ago

Please install redisgraph-py directly from git: pip install git+https://github.com/RedisGraph/redisgraph-py.git

RedisGraph 2.0 (728080f8d6bf72dc12fd90a98f741dbb0f04b74b) is yet to be officially released, it introduces a change to the result-set structure which isn't compatible with RedisGraph-py 1.7

andreaBelmont commented 5 years ago

Thank you this issue is resolved

Guttz commented 5 years ago

For the ones using Docker Images for Redis the same problem will appear if you're using the latest image redislabs/redisgraph

To comply with redisgraph-py:1.7, you should use redislabs/redisgraph:1.2.2.

tsrancsik commented 5 years ago

Hey, This issue is still there. @swilly22 's solution solves the problem.