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
| import com.datastax.driver.core.*; | |
| public class GettingStarted { | |
| public static void main(String[] args) { | |
| Cluster cluster; | |
| Session session; |
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
| package main | |
| import ( | |
| "fmt" | |
| "log" | |
| "github.com/gocql/gocql" | |
| ) | |
| func main() { |
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
| // 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 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
| 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', '[email protected]', 'Bob')") | |
| # Use select to get the user we just entered |
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
| import com.datastax.driver.core.*; | |
| public class GettingStartedTwo { | |
| public static void main(String[] args) { | |
| Cluster cluster; | |
| Session session; | |
| ResultSet results; | |
| Row rows; |
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
| 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 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
| 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 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
| 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 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
| 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', '[email protected]', 'Bob')") | |
| session.execute("SELECT firstname, age FROM users WHERE lastname='Jones'").each do |row| |
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
| 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) | |
OlderNewer