48 releases (18 stable)

4.0.0-beta.1 Jan 29, 2021
3.0.0-beta.2 Mar 29, 2020
2.3.3 Apr 18, 2020
2.3.1 Mar 26, 2020
0.4.0 Dec 29, 2016

#2440 in Database interfaces

Download history 130/week @ 2024-11-16 201/week @ 2024-11-23 136/week @ 2024-11-30 220/week @ 2024-12-07 193/week @ 2024-12-14 105/week @ 2024-12-21 103/week @ 2024-12-28 150/week @ 2025-01-04 242/week @ 2025-01-11 118/week @ 2025-01-18 140/week @ 2025-01-25 307/week @ 2025-02-01 290/week @ 2025-02-08 274/week @ 2025-02-15 357/week @ 2025-02-22 269/week @ 2025-03-01

1,244 downloads per month
Used in 4 crates

MIT/Apache

350KB
9K SLoC

CDRS crates.io version Build Status Build status

CDRS is looking for maintainers

CDRS - Apache Cassandra driver

CDRS is Apache Cassandra driver written in pure Rust.

💡Looking for an async version?

Features

  • TCP/SSL connection;
  • Load balancing;
  • Connection pooling;
  • LZ4, Snappy compression;
  • Cassandra-to-Rust data deserialization;
  • Pluggable authentication strategies;
  • ScyllaDB support;
  • Server events listening;
  • Multiple CQL version support (3, 4), full spec implementation;
  • Query tracing information.

Documentation and examples

Getting started

Add CDRS to your Cargo.toml file as a dependency:

cdrs = { version = "2" }

Then add it as an external crate to your main.rs:

extern crate cdrs;

use cdrs::authenticators::NoneAuthenticator;
use cdrs::cluster::session::{new as new_session};
use cdrs::cluster::{ClusterTcpConfig, NodeTcpConfigBuilder};
use cdrs::load_balancing::RoundRobin;
use cdrs::query::*;

fn main() {
  let node = NodeTcpConfigBuilder::new("127.0.0.1:9042", NoneAuthenticator {}).build();
  let cluster_config = ClusterTcpConfig(vec![node]);
  let no_compression =
    new_session(&cluster_config, RoundRobin::new()).expect("session should be created");

  let create_ks: &'static str = "CREATE KEYSPACE IF NOT EXISTS test_ks WITH REPLICATION = { \
                                 'class' : 'SimpleStrategy', 'replication_factor' : 1 };";
  no_compression.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.

License

This project is licensed under either of

at your option.

Dependencies

~4–12MB
~155K SLoC