1

Well, I started to work with Py2neo and Neo4j in order to initiate a connection between them and already installed both libraries correctly without no errors. When I decide to start training by the following commands:

from py2neo import Graph
graph = Graph("bolt://localhost:7687", user="neo4j", password="mypass")
tx = graph.begin()
for name in ["Mohammad", "Ahmad", "Dad", "Mom"]:
    tx.append("CREATE (person:Person {name:{name}}) RETURN person", name=name)
Mohammad, Ahmad, Dad, Mom = [result.one for result in tx.commit()]

a errors show up:

> AttributeError: 'Transaction' object has no attribute 'append'

is there any solution to eliminate the error, does append attribute expired in py2neo and replaced by a new one?

Mohammad Heydari
  • 3,933
  • 2
  • 26
  • 33
  • 1
    https://py2neo.org/v3/database.html#transactions – slackmart Sep 16 '19 at 14:24
  • Possible duplicate of [How to combine cypher queries into a transaction in Py2neo v3](https://stackoverflow.com/questions/44199114/how-to-combine-cypher-queries-into-a-transaction-in-py2neo-v3) – Pablissimo Sep 16 '19 at 21:25

2 Answers2

2

try using run method:

tx = graph.begin()
tx.run("CREATE (person:Person {name:{name}}) RETURN person", name=name) 
tx.commit()
Tiago Martins Peres
  • 14,289
  • 18
  • 86
  • 145
1

don't use append. firstly you need to create a node, this you can achieve by :-

tx = graph.begin()
a = Node("linkedinn",name="random")
tx.create(a) 
tx.commit()

this way you can create a node in the graph. For now i don't really know why append does not work.I too had the same problem.