CypherSyntaxError: Invalid input 'H': expected 'i/I'

I am getting error while trying to access neo4j enterprise edition 4.0 from python api 4.0.I am using 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):"CREATE (a:Person)-[:KNOWS]->(f:Person {name: $friend}) WHERE = $name RETURN AS friend", name=name, friend=friend)

with driver.session() as session:
session.write_transaction(create_friend_of, "Alice", "Bob")


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 = $name RETURN AS friend"

Please let me know the change I need to do to resolve this error.Thanks in advance.

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.

1 Like

Thanks @stefan.armbruster .Understood the issue here. Quick example code in the below reference requires change.

1 Like

Same error exists for

def create_friend_of(tx, name, friend):"CREATE (a:Person)-[:KNOWS]->(f:Person {name: $friend}) "
"WHERE = $name "
"RETURN AS friend", name=name, friend=friend)

should be

def create_friend_of(tx, name, friend):"CREATE (a:Person)-[:KNOWS]->(f:Person {name: $friend}) "
, name=name, friend=friend)