Search code examples
neo4jneo4j-python-driver

Neo4j Python REST API


Query via Python REST-APi enter image description here message: Invalid input: ':' enter image description here

Hello, i am starting a query via my Python-Neo4j-Api. But the code ist not working, resulting in the the error message above. But the same query is working in the Neo4J Desktop App. Why is it working in the Neo4j Desktop App, but not via my Api Query. Why is the : before param a Problem?

I am new to Python and Neo4j, please help. King regards.

Trying to query via a Python-Neo4j-RestAPI.


Solution

  • Below is the syntax on passing parameters in neo4j python driver. Unfortunately, you cannot use labels or relationship types in the parameter. If you need to pass labels (like Human:Moviestar) then you can use string function in python like this: passing parameters in neo4j using python

    name = "Tom Cruise"
    placeOfBirth = "Syracuse, New York, United States" 
    query = "Create (n:Human:Moviestar { name: $name, placeOfBirth: $placeOfBirth})"
    session = driver.session()
    result = session.run(query, name=name, placeOfBirth=placeOfBirth)