cancel
Showing results for 
Search instead for 
Did you mean: 

Passing paramters to query

drskuce
Node

beginner with ne4j from Python win 10 64 latest neo

from neo4j import *

https://neo4j.com/docs/api/python-driver/1.7/

uri = "bolt://localhost:7687"
d = GraphDatabase.driver(uri, auth=("neo4j", ""))

def do(cypher):
with d.session() as session:
session.run(cypher, name='aaa')

def add_person(d, name):
with d.session() as session:
session.run("CREATE (a:Person {name: $name}), name=name")

add_person(d,"bob")

this simple example gives this error

neobolt.exceptions.ClientError: Expected parameter(s): name

but it works if I dont pass a param but just code the name directly

name='bob'

there is some detail here I cannot find in the documentation
seems pretty simple

thanks

1 REPLY 1

For one you don't have the quotes in the right place. You have:

session.run("CREATE (a:Person {name: $name}), name=name")

when it should be:

session.run("CREATE (a:Person {name: $name})", name=name)