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
// Use Gists to store code you would like to remember later on | |
console.log(window); // log the "window" object to the console |
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
require 'cql' | |
# connect to the cluster | |
client = Cql::Client.connect(hosts: ['127.0.0.1']) | |
client.use('demo') | |
# insert a user | |
client.execute("INSERT INTO users (lastname, age, city, email, firstname) VALUES ('Jones', 35, 'Austin', 'bob@example.com', 'Bob')") | |
# Use select to get the user we just entered |
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
require 'cassandra' | |
cluster = Cassandra.connect | |
#cluster.each_host do |host| | |
# puts "Host #{"127.0.0.1"}: id=#{"6123e2c1-e3ca-4d08-a544-1315b2f399f1"} datacenter=#{"datacenter1"} rack=#{"rack1"}" | |
#end | |
keyspace = 'demo' | |
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
require 'cassandra' | |
cluster = Cassandra.connect | |
keyspace = 'demo' | |
session = cluster.connect(keyspace) | |
session.execute("INSERT INTO users (lastname, age, city, email, firstname) VALUES ('Jones', 35, 'Austin', 'bob@example.com', 'Bob')") | |
session.execute("SELECT firstname, age FROM users WHERE lastname='Jones'").each do |row| |
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
require 'cassandra' | |
cluster = Cassandra.connect | |
#cluster.each_host do |host| | |
# puts "Host #{"127.0.0.1"}: id=#{"6123e2c1-e3ca-4d08-a544-1315b2f399f1"} datacenter=#{"datacenter1"} rack=#{"rack1"}" | |
#end | |
keyspace = 'demo' | |
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
<?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', 'luke@example.com','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
from cqlengine import columns | |
from cqlengine.models import Model | |
class Users(Model): | |
firstname = columns.Text() | |
age = columns.Integer() | |
city = columns.Text() | |
email = columns.Text() | |
lastname = columns.Text(primary_key=True) | |
def __repr__(self): |
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.policies import (TokenAwarePolicy, DCAwareRoundRobinPolicy, RetryPolicy) | |
from cassandra.query import (PreparedStatement, BoundStatement) | |
cluster = Cluster( | |
contact_points=['127.0.0.1'], | |
load_balancing_policy= TokenAwarePolicy(DCAwareRoundRobinPolicy(local_dc='datacenter1')), | |
default_retry_policy = RetryPolicy() | |
) | |
session = cluster.connect('demo') |
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
import com.datastax.driver.core.*; | |
public class GettingStartedTwo { | |
public static void main(String[] args) { | |
Cluster cluster; | |
Session session; | |
ResultSet results; | |
Row rows; |
OlderNewer