在图中创建节点?
Creating a node in a graph?
正在尝试通过 python 创建节点,我做错了什么:
In [1]: import redis
...: from redisgraph import Node, Edge, Graph
In [2]: r = redis.Redis(host='localhost', port=6379)
In [3]: g = Graph('graph', 'r')
In [4]: test3 = Node(label='test3', properties={ 'abc' : 9, 'age': 33})
In [5]: g.add_node(test3)
In [6]: g.commit()
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
<ipython-input-6-b6b3d9b0a206> in <module>()
----> 1 g.commit()
/usr/local/lib/python2.7/dist-packages/redisgraph/client.pyc in commit(self)
134 query = query[:-1]
135
--> 136 return self.query(query)
137
138 def flush(self):
/usr/local/lib/python2.7/dist-packages/redisgraph/client.pyc in query(self, q)
153 statistics = None
154 result_set = None
--> 155 response = self.redis_con.execute_command("GRAPH.QUERY", self.name, q)
156
157 result_set = response[0]
AttributeError: 'str' object has no attribute 'execute_command'
发现错误:
g = Graph('graph', 'r')
应该是:
g = Graph('graph', r)
发现错误:
g = Graph('graph', 'r')
应该是:
g = Graph('graph', r)
正在尝试通过 python 创建节点,我做错了什么:
In [1]: import redis
...: from redisgraph import Node, Edge, Graph
In [2]: r = redis.Redis(host='localhost', port=6379)
In [3]: g = Graph('graph', 'r')
In [4]: test3 = Node(label='test3', properties={ 'abc' : 9, 'age': 33})
In [5]: g.add_node(test3)
In [6]: g.commit()
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
<ipython-input-6-b6b3d9b0a206> in <module>()
----> 1 g.commit()
/usr/local/lib/python2.7/dist-packages/redisgraph/client.pyc in commit(self)
134 query = query[:-1]
135
--> 136 return self.query(query)
137
138 def flush(self):
/usr/local/lib/python2.7/dist-packages/redisgraph/client.pyc in query(self, q)
153 statistics = None
154 result_set = None
--> 155 response = self.redis_con.execute_command("GRAPH.QUERY", self.name, q)
156
157 result_set = response[0]
AttributeError: 'str' object has no attribute 'execute_command'
发现错误:
g = Graph('graph', 'r')
应该是:
g = Graph('graph', r)
发现错误:
g = Graph('graph', 'r')
应该是:
g = Graph('graph', r)