This file contains 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 async = require('async'); | |
var client = new cassandra.Client({contactPoints: ['127.0.0.1'], keyspace: 'demo'}); | |
// Use async series to run functions in serial (one after another) | |
async.series([ | |
// Insert Bob | |
function (callback) { | |
client.execute("INSERT INTO users (lastname, age, city, email, firstname) VALUES ('Jones', 35, 'Austin', '[email protected]', 'Bob')", function (err, result) { |
This file contains 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
<?php | |
$cluster = Cassandra::cluster() | |
->build(); | |
$keyspace = 'killrvideo'; | |
$session = $cluster->connect($keyspace); | |
$statement = $session->execute(new Cassandra\SimpleStatement( | |
"INSERT INTO users (userid, created_date, email, firstname, lastname) VALUES (14c532ac-f5ae-479a-9d0a-36604732e01d, '2013-01-01 00:00:00', '[email protected]','Luke','Tillman')" | |
)); | |
$result = $session->execute(new Cassandra\SimpleStatement("SELECT firstname, lastname, email FROM killrvideo.users WHERE userid=14c532ac-f5ae-479a-9d0a-36604732e01d")); |
This file contains 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
<?php | |
$cluster = Cassandra::cluster() | |
->withPersistentSessions(true) | |
->withTokenAwareRouting(true) | |
->build(); | |
$keyspace = 'killrvideo'; | |
$session = $cluster->connect($keyspace); |
This file contains 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
package com.datastax.quickstart; | |
import com.datastax.oss.driver.api.core.CqlSession; | |
import com.datastax.oss.driver.api.core.cql.*; | |
import java.net.InetSocketAddress; | |
public class GettingStarted { | |
public static void main(String[] args) { |
This file contains 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
using Cassandra; | |
using System.Linq; | |
using System; | |
namespace QuickStart | |
{ | |
class Program | |
{ | |
static void Main(string[] args) | |
{ |
This file contains 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
from cassandra.cluster import Cluster | |
def create_connection(): | |
# TO DO: Fill in your own contact point | |
cluster = Cluster(['127.0.0.1']) | |
return cluster.connect('demo') | |
def set_user(session, lastname, age, city, email, firstname): | |
# TO DO: execute SimpleStatement that inserts one user into the table | |
session.execute("INSERT INTO users (lastname, age, city, email, firstname) VALUES (%s,%s,%s,%s,%s)", [lastname, age, city, email, firstname]) |
This file contains 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
const cassandra = require('cassandra-driver'); | |
// TO DO: Fill in your own host and data center | |
const client = new cassandra.Client({ | |
contactPoints: ['127.0.0.1'], | |
localDataCenter: 'datacenter1', | |
keyspace: 'demo' | |
}); | |
function insertUser(lastname, age, city, email, firstname) { |
This file contains 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
#include <assert.h> | |
#include <stdio.h> | |
#include <stdlib.h> | |
#include <string.h> | |
#include "cassandra.h" | |
struct Users_ { | |
const char* lastname; | |
cass_int32_t age; |
This file contains 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
#include <stdio.h> | |
#include <stdlib.h> | |
#include <string.h> | |
#include <cassandra.h> | |
struct Users_ { | |
const char* lastname; | |
cass_int32_t age; | |
const char* city; |
This file contains 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
from cassandra.cluster import Cluster | |
from cassandra.auth import PlainTextAuthProvider | |
def set_user(session, lastname, age, city, email, firstname): | |
# TO DO: execute SimpleStatement that inserts one user into the table | |
session.execute("INSERT INTO users (lastname, age, city, email, firstname) VALUES (%s,%s,%s,%s,%s)", [lastname, age, city, email, firstname]) | |
def get_user(session, lastname): | |
# TO DO: execute SimpleStatement that retrieves one user from the table | |
# TO DO: print firstname and age of user |