Crates.io | rqlite-rs |
lib.rs | rqlite-rs |
version | 0.3.20 |
source | src |
created_at | 2024-03-15 12:39:14.080423 |
updated_at | 2024-10-18 23:25:39.117709 |
description | Async rqlite client for Rust |
homepage | |
repository | https://github.com/tomvoet/rqlite-rs |
max_upload_size | |
id | 1174720 |
size | 71,470 |
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.
Add to your Cargo.toml
:
[dependencies]
...
+ rqlite-rs = "0.3.20"
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(())
}
The client supports automatic failover, attempting to connect to the next known node if a connection error or timeout occurs, ensuring high availability.
For detailed API documentation and advanced usage, visit rqlite-rs documentation.
Contributions are welcome!
rqlite-rs is licensed under either of
at your option.