Crates.io | rqlite-rs-core |
lib.rs | rqlite-rs-core |
version | |
source | src |
created_at | 2024-03-15 12:23:58.851669+00 |
updated_at | 2025-01-12 14:14:33.327996+00 |
description | Core library for rqlite-rs |
homepage | |
repository | https://github.com/tomvoet/rqlite-rs |
max_upload_size | |
id | 1174712 |
Cargo.toml error: | TOML parse error at line 20, column 1 | 20 | autolib = false | ^^^^^^^ unknown field `autolib`, expected one of `name`, `version`, `edition`, `authors`, `description`, `readme`, `license`, `repository`, `homepage`, `documentation`, `build`, `resolver`, `links`, `default-run`, `default_dash_run`, `rust-version`, `rust_dash_version`, `rust_version`, `license-file`, `license_dash_file`, `license_file`, `licenseFile`, `license_capital_file`, `forced-target`, `forced_dash_target`, `autobins`, `autotests`, `autoexamples`, `autobenches`, `publish`, `metadata`, `keywords`, `categories`, `exclude`, `include` |
size | 0 |
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.6.0"
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(())
}
rqlite-rs supports automatic failover to a different node in the cluster. This can be done using one of the provided fallback strategies (e.g., Random
, RoundRobin
, Priority
).
Furthermore you can also implement your own fallback strategy by implementing the FallbackStrategy
trait. An example of this can be found in the custom_fallback example.
For detailed API documentation and advanced usage, visit rqlite-rs documentation.
Contributions are welcome!
rqlite-rs is licensed under either of
at your option.