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>If you're using a driver, you should be using a parameter for this, which avoids all of the string mangling and stringification problems (which are explicitly recommended against):</p>

<pre><code>query = 'MATCH (n)-[r]-&gt;(m) WHERE ID(n) in {id_list} RETURN n,r,m'
params = {'id_list': [1, 2, 3, 4]}
session.run(statement=query, parameters=params)
</code></pre>

<p>There are several components (labels, relationship types) that cannot be parameterized, but it makes your queries much faster and cleaner to use this feature when possible. Check out <a href="http://neo4j.com/docs/developer-manual/3.0/cypher/#cypher-parameters" rel="nofollow">the docs</a> for more about them.</p>

python neo4j cypher