surrealdb_client

Crates.iosurrealdb_client
lib.rssurrealdb_client
version2.0.0
sourcesrc
created_at2024-07-20 16:17:33.469389
updated_at2024-07-24 11:28:52.717096
descriptionA Rust client for SurrealDB
homepage
repositoryhttps://github.com/Protoculos/surrealdb-client
max_upload_size
id1309572
size17,754
(Protoculos)

documentation

https://docs.rs/surrealdb_client

README

SurrealDB Client

A Rust client library for interacting with SurrealDB.

Features

  • Simple and easy-to-use API
  • Customizable client options
  • Asynchronous SQL execution

Usage

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(())
}

Compatibility

Crate Version Compatible SurrealDB Version
1.5.5 1.5.4
2.0.0 v2.0.0-alpha.7

License

This project is licensed under either of

at your option.

Commit count: 0

cargo fmt