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

**URL:** <https://community.neo4j.com/t/how-to-create-nodes-with-labels-that-are-dynamically-assigned-using-python-driver/44984>\
**Category:** Drivers & Stacks\
**Created:** [September 27, 2021, 3:21pm UTC](https://community.neo4j.com/t/how-to-create-nodes-with-labels-that-are-dynamically-assigned-using-python-driver/44984 "2021-09-27T15:21:48Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![lakshman](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/lakshman/32/15857_2.png) [@lakshman](https://community.neo4j.com/u/lakshman)\
**Post date:** [September 27, 2021, 3:21pm UTC](https://community.neo4j.com/t/how-to-create-nodes-with-labels-that-are-dynamically-assigned-using-python-driver/44984/1 "2021-09-27T15:21:48Z")

</div>

my python code to create a node is

`results=_session.run( 'CALL apoc.cypher.run("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:

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

```

I am using apoc.cypher.run() 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.

---

<div class="post-metadata">

**Author:** ![florent\_biville](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/florent_biville/32/14205_2.png) [@florent\_biville](https://community.neo4j.com/u/florent_biville)\
**Post date:** [September 27, 2021, 4:24pm UTC](https://community.neo4j.com/t/how-to-create-nodes-with-labels-that-are-dynamically-assigned-using-python-driver/44984/2 "2021-09-27T16:24:54Z")

</div>

Labels cannot be used as regular Cypher parameters, unless you use functions such as APOC setLabels: [https://neo4j.com/labs/apoc/4.1/overview/apoc.create/apoc.create.setLabels/](https://neo4j.com/labs/apoc/4.1/overview/apoc.create/apoc.create.setLabels/).  
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.
