cancel
Showing results for 
Search instead for 
Did you mean: 

Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.

Neo.ClientError.Statement.ParameterMissing} {message: Expected parameter(s): username_} with Python

I have the following function and the following call (with the connection setup before it)


from  neo4j import GraphDatabase
from pypher import Pypher
# from WebScraper import *
py = Pypher()
# server connection link
uri = "bolt://localhost:7687"
driver = GraphDatabase.driver(uri, auth=("neo4j", "cs411fpl"))
session = driver.session()
username = 'a'
varray = []
# adds a user node
def add_user(username_):
    q1 = "CREATE (u:User) SET u.name= $username_"
    nodes = session.run(q1)

add_user(username)

This leads to the error:

File "UserHandler.py", line 37, in <module>
    add_user(username)
  
File "UserHandler.py", line 14, in add_user
    nodes = session.run(q1)
  
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/neo4j/work/simple.py", line 217, in run
    self._autoResult._run(query, parameters, self._config.database, self._config.default_access_mode, self._bookmarks, **kwparameters)
  
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/neo4j/work/result.py", line 101, in _run
    self._attach()
  
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/neo4j/work/result.py", line 202, in _attach
    self._connection.fetch_message()
  
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/neo4j/io/_bolt4.py", line 363, in fetch_message
    response.on_failure(summary_metadata or {})
  
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/neo4j/io/_common.py", line 179, in on_failure
    raise Neo4jError.hydrate(**metadata)

neo4j.exceptions.ClientError: {code: Neo.ClientError.Statement.ParameterMissing} {message: Expected parameter(s): username_}

Any suggestions would be great. Thanks!

1 REPLY 1

Hi @rushill2,

Welcome to the Neo4j Community forum!

It looks like your add_user function is not passing along the parameter to to session.run(q1).

To pass parameters along with the query, provide them in the call to session.run(). For example:

nodes = session.run(q1, _username = _username)

For more details and example code, see https://neo4j.com/docs/driver-manual/current/session-api/simple/#driver-simple-autocommit-transactio....

If this was helpful, later when your experience with Neo4j grows, please return to help someone else.

Best,
ABK