Created
March 5, 2019 11:07
-
-
Save devarajchidambaram/4db8c3674f0c2d9375350241d74a3e7a to your computer and use it in GitHub Desktop.
cassendra driver examples
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var cassandra = require('cassandra-driver'); | |
var PlainTextAuthProvider = cassandra.auth.PlainTextAuthProvider; | |
var client = new cassandra.Client({ | |
contactPoints: ["50.112.59.244"], | |
authProvider: new PlainTextAuthProvider('iccassandra', '636fd7882101b8387d4fc43b1ea499ec'), | |
localDataCenter: 'AWS_VPC_US_WEST_2', | |
keyspace: 'keyspace' | |
}); | |
const queries = [{ | |
query: 'INSERT INTO udt_tbl1 (name, email) VALUES (?, ?);', | |
params: ['raj', '[email protected]'] | |
}, { | |
query: 'INSERT INTO udt_tbl1 (name, email) VALUES (?, ?);', | |
params: ['kumar', '[email protected]'] | |
}]; | |
client.batch(queries) | |
.then(result => console.log('Data updated on cluster')).catch(function (err) { | |
console.log("err", err) | |
}); | |
client.execute('select * from emp', function (err, result) { | |
if (err) throw err | |
console.log('User with email', JSON.stringify(result.rows)); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment