Created
September 5, 2014 13:17
-
-
Save beccam/ff2b05c32745d6cc5c85 to your computer and use it in GitHub Desktop.
Getting Started with the Datastax Ruby Driver
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', '[email protected]', 'Bob')") | |
session.execute("SELECT firstname, age FROM users WHERE lastname='Jones'").each do |row| | |
p row | |
end | |
session.execute("UPDATE users SET age = 36 WHERE lastname = 'Jones'") | |
session.execute("SELECT firstname, age FROM users WHERE lastname='Jones'").each do |row| | |
p row | |
end | |
session.execute("DELETE FROM users WHERE lastname = 'Jones'") | |
session.execute("SELECT * FROM users").each do |row| | |
p row | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment