Rust SDK for Spice.ai
Add Spice SDK
cargo add spiceai
Usage with locally running spice runtime
Follow the quickstart guide to install and run spice locally
use spiceai::ClientBuilder;
#[tokio::main]
async fn main() {
let mut client = ClientBuilder::new()
.flight_url("http://localhost:50051")
.build()
.await
.unwrap();
let data = client.query("SELECT trip_distance, total_amount FROM taxi_trips ORDER BY trip_distance DESC LIMIT 10;").await;
}
New client with https://spice.ai cloud
use spiceai::ClientBuilder;
#[tokio::main]
async fn main() {
let mut client = ClientBuilder::new()
.api_key("API_KEY")
.use_spiceai_cloud()
.build()
.await
.unwrap();
}
SQL Query
use spiceai::ClientBuilder;
#[tokio::main]
async fn main() {
let mut client = ClientBuilder::new()
.api_key("API_KEY")
.use_spiceai_cloud()
.build()
.await
.unwrap();
let data = client.query("SELECT * FROM taxi_trips LIMIT 10;").await;
}
Check out our Documentation to learn more about how to use the Rust SDK.