Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/tupshin/cassandra-rs
https://github.com/tupshin/cassandra-rs
Last synced: 9 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/tupshin/cassandra-rs
- Owner: tupshin
- License: apache-2.0
- Created: 2015-01-10T23:47:30.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2020-02-06T02:13:48.000Z (over 4 years ago)
- Last Synced: 2024-06-16T22:20:40.961Z (13 days ago)
- Language: Rust
- Size: 1.27 MB
- Stars: 50
- Watchers: 4
- Forks: 16
- Open Issues: 9
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Lists
- awesome-rust - tupshin/cassandra-rust
- awesome-rust - tupshin/cassandra-rust
README
[![Build Status](https://travis-ci.org/tupshin/cassandra-rs.svg?branch=master)](https://travis-ci.org/tupshin/cassandra-rs)
[![Current Version](http://meritbadge.herokuapp.com/cassandra)](https://crates.io/crates/cassandra)
[![License: MPL-2.0](https://img.shields.io/crates/l/cassandra.svg)](#License)# cassandra-rs
This is a maintained rust project that
exposes the cpp driver at https://github.com/datastax/cpp-driver/
in a somewhat-sane crate.For the wrapper to work, you must first have installed the datastax-cpp driver.
Follow the steps on the cpp driver [docs](https://github.com/datastax/cpp-driver/blob/15215e170810433511c48c304b9e9ca51ff32b2f/topics/building/README.md) to do so.
Make sure that the driver (specifically `libcassandra_static.a` and `libcassandra.so`) are in your `/usr/local/lib64/` directory
You can use it from cargo with
```toml
[dependencies.cassandra]
git = "https://github.com/tupshin/cassandra-rs"
```Or just
```toml
[dependencies]
cassandra="*"
```Here's a straightforward example found in simple.rs:
```rust
#[macro_use(stmt)]
extern crate cassandra;
use cassandra::*;
use std::str::FromStr;
fn main() {
let query = stmt!("SELECT keyspace_name FROM system_schema.keyspaces;");
let col_name = "keyspace_name";
let contact_points = ContactPoints::from_str("127.0.0.1").unwrap();
let mut cluster = Cluster::default();
cluster.set_contact_points(contact_points).unwrap();
cluster.set_load_balance_round_robin();
match cluster.connect() {
Ok(ref mut session) => {
let result = session.execute(&query).wait().unwrap();
println!("{}", result);
for row in result.iter() {
let col: String = row.get_col_by_name(col_name).unwrap();
println!("ks name = {}", col);
}
}
err => println!("{:?}", err),
}
}
```There's additional examples included with the project in src/examples.