Skip to Content
ExamplesQuickstart

Quickstart

The smallest Rust example: connect to KalamDB, authenticate, and run one SQL query.

Source: link/sdks/rust/examples/quickstart/

What it does

  • Builds a KalamLinkClient with a server URL and credentials
  • Runs SELECT CURRENT_USER()
  • Prints the result and disconnects

No WebSocket or subscriptions — just HTTP SQL.

Run it

BASH
cd link/sdks/rustexport KALAMDB_SERVER_URL=http://localhost:2900export KALAMDB_ROOT_PASSWORD=kalamdb123cargo run -p quickstart

Expected output:

TEXT
status: Okcurrent user row: ...

Source walkthrough

RUST
use std::time::Duration; use kalam_client::{AuthProvider, KalamLinkClient}; fn server_url() -> String {    std::env::var("KALAMDB_SERVER_URL").unwrap_or_else(|_| "http://localhost:2900".to_string())} fn auth() -> AuthProvider {    let password =        std::env::var("KALAMDB_ROOT_PASSWORD").unwrap_or_else(|_| "kalamdb123".to_string());    AuthProvider::system_user_auth(password)} #[tokio::main]async fn main() -> Result<(), Box<dyn std::error::Error>> {    let client = KalamLinkClient::builder()        .base_url(server_url())        .auth(auth())        .timeout(Duration::from_secs(30))        .build()?;     let response = client        .execute_query("SELECT CURRENT_USER()", None, None, None)        .await?;     println!("status: {:?}", response.status);    if let Some(result) = response.results.first() {        if let Some(rows) = &result.rows {            for row in rows {                println!("current user row: {row:?}");            }        }    }     client.disconnect().await;    Ok(())}

Use in your own project

Install from crates.io :

BASH
cargo add kalam-clientcargo add tokio --features macros,rt-multi-thread

See Setup & Quick Start for the full install guide.

Next

Last updated on