Pregunta

I'm trying to execute a simple parameterized cypher query which actually fails due to a syntax error.

params = {
   "k" : k,
   "v" : v,
   "p": {
      "name": "marc"
   }
}

query = "CYPHER 2.0 MATCH (n { { k } : { v } }) SET { p } RETURN n"
data, metadata = cypher.execute(graph_db, query, params=params)

...

SyntaxException: Invalid input '{': expected whitespace, comment, an identifier, '}' or UnsignedInteger (line 1, column 12)
"MATCH (n { { k } : { v } }) SET { p } RETURN n"

I'm using py2neo 1.6.3 with flask.

Thanks in advance!

/Marc

¿Fue útil?

Solución

Parameters are only allowed in certain places. Try the following statement:

MATCH (n { k : { valueParam } }) SET { n.name = { nameParam } } RETURN n

Your map would contain:

params = {
   "valueParam " : "v",
   "nameParam " : "marc"
}

To state the Cypher docs:

Parameters can not be used as for property names, relationship types and labels, since these patterns are part of the query structure that is compiled into a query plan.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top