in nodejs/datastax-v4/ecs-sigv4/app/load-data/load-data.js [42:80]
async function runLoadData() {
try {
// Create table
await cassandraClient.execute(
`CREATE TABLE IF NOT EXISTS ${keyspace}.countries(
id text PRIMARY KEY,
name text,
capital text,
population int,
area int
);`
)
// Wait for table creation to finish by polling status
await tableCreated(keyspace, table)
// Load data
const insertQuery = `INSERT INTO ${keyspace}.${table} (id, name, capital, population, area)
VALUES (?, ?, ?, ?, ?)`
const insertParameters = [
["cn","China","Beijing",1398000000,9597000],
["in","India","New Delhi",1366000000,3287000],
["gb","United Kingdon","London",66650000,242495],
["mt","Malta","Valletta",502653,316],
["us","United States","Washington DC",328200000,9834000]
];
const results = await cassandra.concurrent.executeConcurrent(
cassandraClient, insertQuery, insertParameters
)
log.info(results)
}
catch (err) {
log.error(err)
}
finally {
if (cassandraClient)
await cassandraClient.shutdown()
}
}