CassandraDB

Gem Version CI Coverage Status Code Climate

Cassandra DB adapter inspired on Sequel

Installation

Add this line to your application's Gemfile:

gem 'cassandra_db'

And then execute:

$ bundle

Or install it yourself as:

$ gem install cassandra_db

Usage

Connect

db = CassandraDB.connect hosts: ['localhost'], port: 9042, keyspace: 'system'

Metadata

db.keyspace # => :system

db.keyspaces # => [:system, :system_traces]

db.tables # => Array of table names in current keyspace

Change keyspace

db.use_keyspace 'my_keyspace'
db.keyspace # => :my_keyspace

Create and drop keyspaces

replication_opts = {
  class: 'SimpleStrategy',
  replication_factor: 1
}
db.create_keyspace :my_keyspace, replication: replication_opts, durable_writes: true

db.drop_keyspace :my_keyspace

Queries

dataset = db[table_name] # => CassandraDB::Dataset
dataset = db[table_name].where(field: 'value') # => CassandraDB::Dataset

Dataset/Enumerable methods

dataset.count
dataset.each
dataset.map
dataset.all

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/gabynaiman/cassandra_db.

License

The gem is available as open source under the terms of the MIT License.