Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/300.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/csharp-4.0/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python neo4j.v1驱动程序返回的数据结构_Python_Neo4j_Graph Databases - Fatal编程技术网

Python neo4j.v1驱动程序返回的数据结构

Python neo4j.v1驱动程序返回的数据结构,python,neo4j,graph-databases,Python,Neo4j,Graph Databases,我正在使用neo4j(neo4j.v1)的python驱动程序,我正在阅读文档以及neo4j网站中的各种启动程序代码 到目前为止,我编写的代码: from neo4j.v1 import GraphDatabase, basic_auth import sys class boltSession(object): def __init__(self, uri, user, password): self._driver = GraphDatabase.driver(uri, au

我正在使用neo4j(neo4j.v1)的python驱动程序,我正在阅读文档以及neo4j网站中的各种启动程序代码

到目前为止,我编写的代码:

from neo4j.v1 import GraphDatabase, basic_auth
import sys

class boltSession(object):

  def __init__(self, uri, user, password):
    self._driver = GraphDatabase.driver(uri, auth=(user, password))

  def close(self):
    self._driver.close()

  def get_people(self, attr):
    with self._driver.session() as session:
      return session.read_transaction(self.match_people_node, attr)

  def add_person(self, attr):
    with self._driver.session() as session:
      return session.write_transaction(self.create_person_node, attr)

  def get_person(self, name):
    with self._driver.session() as session:
      session.read_transaction(self.match_person_node, name)
      return

  @staticmethod
  def match_people_node(tx, attr):
    name = attr['name']
    result = tx.run("MATCH (a:Person{name: $name}) RETURN a", name = name)
    return [record["a"] for record in result]

  @staticmethod
  def match_person_node(tx,name):
    result = tx.run("MATCH (a:Person {name: $name}) RETURN count(a)", name=name)
    return result.single()[0]

  @staticmethod
  def create_person_node(tx, attr):
    name = attr['name']
    country = attr['country']
    result = tx.run("CREATE (a:Person {name: $name, country: $country})",
      name = name,
      country = country)
    return result

uri = 'bolt://localhost:7687'
user = 'neo4j'

password = 'neo4j'
neoSession = boltSession(uri, user, password)

attr1 = {} ; attr1['name'] = 'Joe' ; attr1['country'] = 'USA' ;
attr2 = {} ; attr2['name'] = 'Mat' ; attr2['country'] = 'USA' ;
attr3 = {} ; attr3['name'] = 'Joe' ; attr3['country'] = 'AUS' ;

neoSession.add_person(attr1)
neoSession.add_person(attr2)
neoSession.add_person(attr3)

seek1 = {} ; seek1['name'] = 'Joe'
seek2 = {} ; seek2['country'] = 'USA'

print neoSession.get_people(seek1)

neoSession.close()
这段代码使用python2.7,为数据库分配了3个节点,read_事务返回如下数据结构:

<Node id=1555 labels=set([u'Person']) properties={u'country': u'USA', u'name': u'Joe'}>

有没有办法将其转换为熟悉的Python数据结构?我现在完全不知所措