cancel
Showing results for 
Search instead for 
Did you mean: 

Set label to node while creating it using official neo4j python driver

ranjanr331
Node Link

How to set label to a node while creating it. I'm using following query to create the node:
session.run(query="CREATE (x) set x = $dict_param", parameters={'dict_param' : {'itemName':'Jacket', 'price':2199}) and want to set label 'itemName' to it.

2 REPLIES 2

Cobra
Ninja
Ninja

Hello @ranjanr331

You have to use APOC since it's not possible in classic Cypher.

session.run(
    query="CALL apoc.create.node([$dict_param.itemName], $dict_param)",
    parameters={'dict_param': {'itemName': 'Jacket', 'price': 2199}
)

Regards,
Cobra

okay. Will try this one

Nodes 2022
Nodes
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.