26 releases

0.4.0 Nov 25, 2024
0.3.20 Oct 18, 2024
0.3.19 Jul 20, 2024
0.3.18 Jun 30, 2024
0.2.3 Mar 15, 2024

#1320 in Database interfaces

Download history 65/week @ 2024-09-16 31/week @ 2024-09-23 27/week @ 2024-09-30 193/week @ 2024-10-14 63/week @ 2024-10-21 27/week @ 2024-11-11 2/week @ 2024-11-18 143/week @ 2024-11-25 59/week @ 2024-12-02

231 downloads per month

MIT/Apache

80KB
2K SLoC

rqlite-rs

build status Test Coverage Crates.io Documentation License Crates.io Rust

rqlite-rs is a Rust client for rqlite, the distributed relational database built on SQLite, providing an async interface for seamless integration with Rust's async ecosystems. Utilizing reqwest for efficient connection management, it offers a Rustic, high-level API for easy and efficient interaction with rqlite clusters.

Features

  • Asynchronous Interface: Fully async, compatible with Tokio, async-std, and smol.
  • Connection Pooling: Efficient management of connections to the rqlite cluster.
  • High-Level API: Simplifies interactions with the rqlite API.
  • Resilience: Automatic failover to a secondary node on connectivity issues.
  • Cluster Management: Full control over the cluster with node query and management features.

Installation

Add to your Cargo.toml:

[dependencies]
...
+ rqlite-rs = "0.4.0"

Quick Start

Ensure you have a running rqlite cluster. Replace localhost:4001 and localhost:4002 with your node addresses:

use rqlite_rs::prelude::*;

#[derive(FromRow)]
pub struct Table {
    name: String,
}

#[tokio::main]
async fn main() -> anyhow::Result<()> {
    let client = RqliteClientBuilder::new()
        .known_host("localhost:4001")
        .build()?;

    let query = rqlite_rs::query!(
        "SELECT name FROM sqlite_master WHERE type='table' AND name NOT LIKE 'sqlite_%'"
    )?;

    let rows = client.fetch(query).await?;

    let tables = rows.into_typed::<Table>()?;

    for table in tables {
        println!("Table: {}", table.name);
    }

    Ok(())
}

Resilience

The client supports automatic failover, attempting to connect to the next known node if a connection error or timeout occurs, ensuring high availability.

Documentation

For detailed API documentation and advanced usage, visit rqlite-rs documentation.

Contributing

Contributions are welcome!

License

rqlite-rs is licensed under either of

at your option.

Dependencies

~4–15MB
~198K SLoC