title: Cassandra Batch Insert in Python
body: <p>I need to do a batch <code>INSERT</code> in <code>Cassandra</code> using <code>Python</code>.
  I am using the latest <code>Datastax</code> python driver.</p>
  
  <p>The <code>INSERTS</code> are batches of columns that will be in the same row. I will have many rows to insert, but chunks of the data will be in the same row.</p>
  
  <p>I can do individual <code>INSERTS</code> in a <code>for loop</code> as described in this post:
  <a href="https://stackoverflow.com/questions/15683989/parameterized-queries-with-the-python-cassandra-module">Parameterized queries with the Python Cassandra Module</a>
  I am using parametrized query, values as shown in that example.</p>
  
  <p>This did not help:
  <a href="https://stackoverflow.com/questions/17885238/how-to-multi-insert-rows-in-cassandra">How to multi insert rows in cassandra</a></p>
  
  <p>I am not clear how to assemble a parameterized INSERT: </p>
  
  <pre><code>BEGIN BATCH  
    INSERT(query values1)  
    INSERT(query values2)  
    ...  
  APPLY BATCH;  
  cursor.execute(batch_query)  
  </code></pre>
  
  <p>Is this even possible? Will this speed up my <code>INSERTS</code>? I have to do millions. Even thousands take too long.
  I found some Java info:
  <a href="http://www.datastax.com/dev/blog/client-side-improvements-in-cassandra-2-0" rel="nofollow noreferrer">http://www.datastax.com/dev/blog/client-side-improvements-in-cassandra-2-0</a></p>