#cassandra #cql #database-driver #tokio #async-api

scylla

Async CQL driver for Rust, optimized for Scylla, fully compatible with Apache Cassandra™

29 releases (13 breaking)

0.14.0 Sep 5, 2024
0.13.1 Jul 11, 2024
0.12.0 Feb 2, 2024
0.11.1 Dec 21, 2023
0.2.1 Jul 26, 2021

#39 in Database interfaces

Download history 34345/week @ 2024-07-08 25828/week @ 2024-07-15 26215/week @ 2024-07-22 27766/week @ 2024-07-29 31716/week @ 2024-08-05 31482/week @ 2024-08-12 30807/week @ 2024-08-19 42087/week @ 2024-08-26 35304/week @ 2024-09-02 36432/week @ 2024-09-09 33964/week @ 2024-09-16 37162/week @ 2024-09-23 40880/week @ 2024-09-30 29974/week @ 2024-10-07 44022/week @ 2024-10-14 37736/week @ 2024-10-21

153,228 downloads per month
Used in 41 crates (31 directly)

MIT/Apache

2MB
43K SLoC

ScyllaDB Rust Driver

Crates.io docs.rs minimum rustc version

This is a client-side driver for ScyllaDB written in pure Rust with a fully async API using Tokio. Although optimized for ScyllaDB, the driver is also compatible with Apache Cassandra®.

Note: this driver is officially supported but currently available in beta. Bug reports and pull requests are welcome!

Getting Started

The documentation book is a good place to get started. Another useful resource is the Rust and Scylla lesson on Scylla University.

Examples

use futures::TryStreamExt;

let uri = "127.0.0.1:9042";

let session: Session = SessionBuilder::new().known_node(uri).build().await?;

let raw_iter = session.query_iter("SELECT a, b, c FROM ks.t", &[]).await?;
let mut iter = raw_iter.into_typed::<(i32, i32, String)>();
while let Some((a, b, c)) = iter.try_next().await? {
    println!("a, b, c: {}, {}, {}", a, b, c);
}

Please see the full example program for more information. You can also run the example as follows if you have a Scylla server running:

SCYLLA_URI="127.0.0.1:9042" cargo run --example basic

All examples are available in the examples directory

Features and Roadmap

The driver supports the following:

  • Asynchronous API
  • Token-aware routing
  • Shard-aware routing (specific to ScyllaDB)
  • Prepared statements
  • Query paging
  • Compression (LZ4 and Snappy algorithms)
  • CQL binary protocol version 4
  • Batch statements
  • Configurable load balancing policies
  • Driver-side metrics
  • TLS support - install openssl if you want to use it https://docs.rs/openssl/0.10.32/openssl/#automatic
  • Configurable retry policies
  • Authentication support
  • CQL tracing

Ongoing efforts:

  • CQL Events
  • More tests
  • More benchmarks

Getting Help

Please join the #rust-driver channel on ScyllaDB Slack to discuss any issues or questions you might have.

Supported Rust Versions

Our driver's minimum supported Rust version (MSRV) is 1.66.0. Any changes will be explicitly published and will only happen during major releases.

Reference Documentation

Other Drivers

License

This project is licensed under either of

at your option.

Dependencies

~9–19MB
~254K SLoC