Skip to content

Instantly share code, notes, and snippets.

@beccam
Created September 5, 2014 13:17
Show Gist options
  • Save beccam/ff2b05c32745d6cc5c85 to your computer and use it in GitHub Desktop.
Save beccam/ff2b05c32745d6cc5c85 to your computer and use it in GitHub Desktop.
Getting Started with the Datastax Ruby Driver
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