Insert multiple rows in Cassandra

2,744 views
Skip to first unread message

amit tewari

unread,
Jul 20, 2015, 2:47:37 AM7/20/15
to nodejs-dr...@lists.datastax.com
Hi, how can I insert multiple rows (say 10K rows) into Cassandra using the nodejs driver?

I have found some articles which talk about Prepared Statements etc., but they seem to be for Java

Thanks
AT

Alex Popescu

unread,
Jul 21, 2015, 12:24:24 AM7/21/15
to nodejs-dr...@lists.datastax.com, amitte...@gmail.com
Hi Amit, 

Besides minor API differences, all the DataStax drivers for Cassandra provide the same features and behave the same so you
can use the best documentation and just translate it to the API of the driver you are using. A couple of resources that could be
helpful to getting you started:



-- 
Bests,

Alex Popescu | @al3xandru
Sen. Product Manager @ DataStax



Gaurav Gupta

unread,
Jul 21, 2015, 2:45:33 AM7/21/15
to amitte...@gmail.com, nodejs-dr...@lists.datastax.com
Hi Amit,

You can create 10K queries using either prepared statement or raw statement. After construction of query, execute them in a batch.

CassandraDriverObject.batch(arg1, arg2, cb) is the function for you.
This function takes following arguments:
  1. arg1 = An array of object.
        Object structure: {query: 'select * from mytable where column1=?', params: ['value1']}
  2. arg2 = An object with structure {hints: allQueryHints};
      1. allQueryhints is an array of hints for each query. A hint for single query looks like: ['varchar']. Hence allQueryhints will look like: [['varchar']]
To unsubscribe from this group and stop receiving emails from it, send an email to nodejs-driver-u...@lists.datastax.com.

-- 
Best regards,

Gaurav Gupta

TERMS OF USE:
The contents of this email are confidential to the intended recipient at the email address to which it has been addressed.  It may not be disclosed to or used by anyone other than this addressee, nor may it be copied in any way. If received in error, please contact Impressico Business Solutions, on +91-120-419-0000 quoting the name of the sender and the addressee and then delete it from your system. Please note that neither Impressico Business Solutions, nor the sender accepts any responsibility for viruses and it is your responsibility to scan the email and attachments (if any).

Alex Popescu

unread,
Jul 22, 2015, 2:51:56 AM7/22/15
to DataStax Node.js Driver for Apache Cassandra Mailing List, gaurav...@impressico.com, amitte...@gmail.com


On Monday, July 20, 2015 at 11:45:33 PM UTC-7, Gaurav Gupta wrote:
Hi Amit,

You can create 10K queries using either prepared statement or raw statement. After construction of query, execute them in a batch.

Without knowing all the details of what Amit's requirements are, I'd suggest staying away from using Batch. This post explains the pros & cons of using batches and the alternative solutions:

Reply all
Reply to author
Forward
0 new messages