does neo4j allows parameterized value for the label?
query = ( "CREATE (n: $node_type {ID: $id_value, Type: $node_type, Name: $name, Parent: $parent, Child: $child, Role: $role})" )
I am using python language
Thanks.
does neo4j allows parameterized value for the label?
query = ( "CREATE (n: $node_type {ID: $id_value, Type: $node_type, Name: $name, Parent: $parent, Child: $child, Role: $role})" )
I am using python language
Thanks.
as from the Neo4j v5 documentation, but also applicable for prior versions,
Parameters cannot be used for the following constructs, as these form part of the query structure that is compiled into a query plan:
property keys; so MATCH (n) WHERE n.$param = 'something' is invalid
relationship types; so MATCH (n)-[:$param]→(m) is invalid
labels; so MATCH (n:$param) is invalid
Parameters may consist of letters and numbers, and any combination of these, but cannot start with a number or a currency symbol.
Thanks @dana_canzano.
I checked this query, this is working.
query = (
"CREATE (n:" + node_type + "
{ID: $id_value, Name: $name, Parent: $parent, Child: $child, Role: $role})"
)
... just remember that string concatenation like this is how injection attacks start. Make sure you validate node_type if it is something a user can provide
Thank you @john.stegeman