Crates.io | surrealdb_client |
lib.rs | surrealdb_client |
version | 2.0.0 |
source | src |
created_at | 2024-07-20 16:17:33.469389 |
updated_at | 2024-07-24 11:28:52.717096 |
description | A Rust client for SurrealDB |
homepage | |
repository | https://github.com/Protoculos/surrealdb-client |
max_upload_size | |
id | 1309572 |
size | 17,754 |
A Rust client library for interacting with SurrealDB.
Add this to your Cargo.toml
:
[dependencies]
surrealdb_client = "2.0.0"
Here's a quick example:
Using with default settings:
use surrealdb_client::{SurrealDBClient, ClientOptions};
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let default_client = SurrealDBClient::new(ClientOptions::default())?;
let result = default_client.execute_sql("SELECT * FROM accounts").await?;
println!("Result: {}", result);
Ok(())
}
Using with user settings:
use surrealdb_client::{SurrealDBClient, ClientOptions};
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let custom_options = ClientOptions::new(
"crypto".to_string(),
"crypto".to_string(),
"http://localhost:8000/sql".to_string(),
Some("root".to_string()),
Some("root".to_string()),
);
let custom_client = SurrealDBClient::new(custom_options)?;
let result = custom_client.execute_sql("SELECT * FROM accounts").await?;
println!("Result: {}", result);
Ok(())
}
Crate Version | Compatible SurrealDB Version |
---|---|
1.5.5 | 1.5.4 |
2.0.0 | v2.0.0-alpha.7 |
This project is licensed under either of
at your option.