Neo4j how to handle special characters like ” \\ in Cypher statements

ぃ、小莉子 提交于 2019-11-29 16:47:24

If you want to include double quotes, you can wrap in single quotes:

CREATE (n:Node {name:'hello " world'}) 
RETURN n.name

n.name
hello " world

If you want to include single quotes, you can wrap in double quotes:

CREATE (n:Node {name:"hello ' world"}) 
RETURN n.name

n.name
hello ' world

If it's more complicated than that, you can escape the character:

CREATE (n:Node {name:"hello \" world"}) 
RETURN n.name

n.name
hello " world

You can also include backslashes by escaping them:

CREATE (n:Node {name:"hello \\ world"}) 
RETURN n.name

n.name
hello \ world

I would suggest to use parameters, then the cypher parser doesn't see them.

And it's just an name -> string you pass via a dictionary to the execute method.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!