Data structure returned by the Python neo4j.v1 driver -


i working python driver neo4j (neo4j.v1) , working way through documentation, various starter codes found within neo4j website.

the code i've produced, far:

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):     self._driver.session() session:       return session.read_transaction(self.match_people_node, attr)    def add_person(self, attr):     self._driver.session() session:       return session.write_transaction(self.create_person_node, attr)    def get_person(self, name):     self._driver.session() 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"] 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() 

this code works w/ python2.7, assigns 3 nodes database, , read_transaction returns datastructure looks this:

<node id=1555 labels=set([u'person']) properties={u'country': u'usa', u'name': u'joe'}> 

is there way cast familiar python data structure? @ complete loss right now.


Comments

Popular posts from this blog

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

python Tkinter Capturing keyboard events save as one single string -

sql server - Why does Linq-to-SQL add unnecessary COUNT()? -