Python neo4j

I am running this code and the first parameter is getting passed but the number in the reursive depth $n gives the error:
CypherSyntaxError: {code: Neo.ClientError.Statement.SyntaxError} {message: Parameter maps cannot be used in MATCH patterns (use a literal map instead, eg. "{id: {param}.id}")

Here is my code. If I put any number like 2 instead of $n it works:

params = {"prot": 'C', "n": 2}
    with session.begin_transaction() as tx:
        result ="MATCH p = (n:Protein { name:$prot })<-[:REGULATES*1..$n]->(b:Protein) \
                     WITH *, relationships(p) AS rs \
                     RETURN \
                         startNode(last(rs)).name AS Protein1, \
                         last(rs).direction AS Regulates, \
                         endNode(last(rs)).name AS Protein2, \
                         length(p) AS pathLength",

I'm not at my computer with neo4j, but have you tried renaming either your 'n' parameter or the 'n' variable in your first Protein node? Using the same name in both places might be confusing Cypher.

1 Like