Skip to content

Instantly share code, notes, and snippets.

@careo
Created August 13, 2010 00:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save careo/521994 to your computer and use it in GitHub Desktop.
Save careo/521994 to your computer and use it in GitHub Desktop.
require 'rubygems'
require 'cassandra/0.7'
cassandra = Cassandra.new "system"
keyspaces = cassandra.send(:client).describe_keyspaces
keyspace_name = "SomeTest"
cf_name = "Tests"
if keyspaces.include? keyspace_name
p cassandra.drop_keyspace keyspace_name
end
cf_def = Cassandra::ColumnFamily.new :keyspace => keyspace_name,
:name => cf_name
ks_def = Cassandra::Keyspace.new :name => "SomeTest",
:strategy_class => "org.apache.cassandra.locator.RackUnawareStrategy",
:replication_factor => 1,
:cf_defs => [cf_def]
p cassandra.add_keyspace ks_def
p cassandra.send(:client).describe_keyspaces
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment