Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
07-20-2020 01:58 AM
I am getting error while trying to access neo4j enterprise edition 4.0 from python api 4.0.I am using https://neo4j.com/docs/api/python-driver/4.0/ for reference.
Used below code -
<
from neo4j import GraphDatabase
uri = "neo4j://localhost:7687"
driver = GraphDatabase.driver(uri, auth=("neo4j", "pwd"))
def create_friend_of(tx, name, friend):
tx.run("CREATE (a:Person)-[:KNOWS]->(f:Person {name: $friend}) WHERE a.name = $name RETURN f.name AS friend", name=name, friend=friend)
with driver.session() as session:
session.write_transaction(create_friend_of, "Alice", "Bob")
driver.close()
Getting below error
CypherSyntaxError: Invalid input 'H': expected 'i/I' (line 1, column 57 (offset: 56))
"CREATE (a:Person)-[:KNOWS]->(f:Person {name: $friend}) WHERE a.name = $name RETURN f.name AS friend"
Please let me know the change I need to do to resolve this error.Thanks in advance.
Solved! Go to Solution.
07-21-2020 12:12 PM
You cannot have a WHERE
after a CREATE
. Not sure what you intend to do, but most likely you want to do a MATCH
with a WHERE
first to find a existing node and then use a simple CREATE for the relationship and the other node.
07-21-2020 12:12 PM
You cannot have a WHERE
after a CREATE
. Not sure what you intend to do, but most likely you want to do a MATCH
with a WHERE
first to find a existing node and then use a simple CREATE for the relationship and the other node.
07-21-2020 09:20 PM
Thanks @stefan.armbruster .Understood the issue here. Quick example code in the below reference requires change.
09-03-2020 08:23 AM
Same error exists for https://neo4j.com/docs/api/python-driver/current/
def create_friend_of(tx, name, friend):
tx.run("CREATE (a:Person)-[:KNOWS]->(f:Person {name: $friend}) "
"WHERE a.name = $name "
"RETURN f.name AS friend", name=name, friend=friend)
should be
def create_friend_of(tx, name, friend):
tx.run("CREATE (a:Person)-[:KNOWS]->(f:Person {name: $friend}) "
, name=name, friend=friend)
All the sessions of the conference are now available online