4 releases (stable)

2.0.0 Jul 24, 2024
1.5.5 Jul 24, 2024
0.1.0 Jul 20, 2024

#2880 in Database interfaces

Download history 96/week @ 2024-07-16 249/week @ 2024-07-23 14/week @ 2024-07-30 3/week @ 2024-09-10 1/week @ 2024-09-17 12/week @ 2024-09-24 4/week @ 2024-10-01

63 downloads per month

MIT/Apache

7KB
73 lines

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.

Dependencies

~7–18MB
~255K SLoC