Concatenate list Object to cypher
<p>I am using Neo4j Bolt Driver and executing few queries where I have to check the node in a list of id's.</p>

<p>Query:</p>

<pre><code>MATCH (n)-[r]-&gt;(m) WHERE ID(n) in [1,2,3,4] RETURN n,r,m
</code></pre>

<p>Doing the same with python fails:</p>

<pre><code>l = [1,2,3,4]
query = 'MATCH (n)-[r]-&gt;(m) WHERE ID(n) in '+list+' RETURN n,r,m'
</code></pre>

<p>The execution fails with this error:</p>

<pre><code>query = 'MATCH (n)-[r]-&gt;(m) WHERE ID(n)' in '+list+' RETURN n,r,m'
TypeError: cannot concatenate 'str' and 'int' objects
</code></pre>

<p>How can we achieve this?</p>

<p>Your <code>list</code> is not of type String (str). As there is no natural way of concatenation of <code>int</code> and <code>str</code>, you're getting this error.</p>

<p>Making <code>list</code>  string like <code>list = '[1,2,3,4]'</code> would help.</p>

<p>Btw <code>list</code> is a reserved keyword in python. You should use a different name.</p>

python neo4j cypher