23 releases

0.3.18 Jun 30, 2024
0.3.17 Jun 30, 2024
0.3.15 May 3, 2024
0.3.14 Apr 22, 2024
0.2.3 Mar 15, 2024

#846 in Database interfaces

Download history 321/week @ 2024-03-21 183/week @ 2024-03-28 282/week @ 2024-04-04 446/week @ 2024-04-11 280/week @ 2024-04-18 34/week @ 2024-04-25 180/week @ 2024-05-02 5/week @ 2024-05-09 5/week @ 2024-05-16 7/week @ 2024-05-23 142/week @ 2024-05-30 29/week @ 2024-06-06 5/week @ 2024-06-13 238/week @ 2024-06-27 25/week @ 2024-07-04

269 downloads per month

MIT license

79KB
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.3.18"

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 the MIT license. See LICENSE for details.

Dependencies

~4–18MB
~225K SLoC