Showing results for 
Search instead for 
Did you mean: 

How to create nodes with labels that are dynamically assigned using Python driver

Node Link

my python code to create a node is 'CALL"merge (s:SHOT:$videoshot) return s", {'videoshot': 'Matrix'}' )

Want to create a Node with multiple labels, one of the labels is computed. running the above code gives the following error:

create shot exception {code: Neo.ClientError.Statement.SyntaxError} {message: Invalid input '{': expected "+" or "-" (line 1, column 60 (offset: 59))
"CALL"merge (s:SHOT:$videoshot) return s", {'videoshot': 'Matrix'}) - call apoc with params substitution is not working"                      ^

I am using since I found out that regular cypher does not support dynamic node labels. software version I am using are:
python driver version neo4j==4.3.5
python 3.8
OS - ubuntu 20.04

help would be much appreciated.


Labels cannot be used as regular Cypher parameters, unless you use functions such as APOC setLabels: apoc.create.setLabels - APOC Documentation.
You can also work around this with basic string concatenation, but make sure your labels are sanitized or else the code will be vulnerable to Cypher injections.

Nodes 2022
NODES 2022, Neo4j Online Education Summit

On November 16 and 17 for 24 hours across all timezones, you’ll learn about best practices for beginners and experts alike.