CDRS is Apache Cassandra driver written in pure Rust.
đź’ˇLooking for an async version? - https://github.com/AlexPikalov/cdrs-async
Add CDRS to your Cargo.toml
file as a dependency:
toml
cdrs = { version = "2" }
Then add it as an external crate to your main.rs
:
```rust extern crate cdrs;
use cdrs::authenticators::NoneAuthenticator; use cdrs::cluster::session::{new as newsession}; use cdrs::cluster::{ClusterTcpConfig, NodeTcpConfigBuilder}; use cdrs::loadbalancing::RoundRobin; use cdrs::query::*;
fn main() { let node = NodeTcpConfigBuilder::new("127.0.0.1:9042", NoneAuthenticator {}).build(); let clusterconfig = ClusterTcpConfig(vec![node]); let nocompression = newsession(&clusterconfig, RoundRobin::new()).expect("session should be created");
let createks: &'static str = "CREATE KEYSPACE IF NOT EXISTS testks WITH REPLICATION = { \ 'class' : 'SimpleStrategy', 'replicationfactor' : 1 };"; nocompression.query(create_ks).expect("Keyspace create error"); } ```
This example configures a cluster consisting of a single node, and uses round robin load balancing and default r2d2
values for connection pool.
This project is licensed under either of
at your option.