I have an issue in my code Python code. I'm using GQLAlchemy and Memgraph 2.7
The function cypherQueryCreator.createCypherQuery in my program doesn't appear to be handling apostrophes (ticks) correctly. I have a node in a NetworkX graph that looks kind fo like this:
netNode = (15981, { 'category': 'Lexeme', 'Term': "Can't", 'Phonetics': 'k æ n t' })
When I watn to generate a cypher query, the output that I get is CREATE (:Lexeme {Term: 'Can't', Phonetics: 'k æ n t', id: 15981});
and it is not a wonder that it doesn't work since \
is missing in front of '
. I was hoping to get this code CREATE (:Lexeme {Term: 'Can\'t', Phonetics: 'k æ n t', id: 15981});
Do you have any tips for me?
This is a known bug, and there is a workaround solution offert in GitHub issue. The code that should help you is escape_apostrophes = lambda x: re.compile(r"(['])").sub(r"\\'", x)