LibSQL
libSQL service support.
Capabilities
This service can be used to:
- stat
- read
- write
- create_dir
- delete
- copy
- rename
-
list -
presign - blocking
Configuration
root
: Set the working directory ofOpenDAL
connection_string
: Set the connection string for libsql serverauth_token
: Set the authentication token for libsql servertable
: Set the table of libsqlkey_field
: Set the key field of libsqlvalue_field
: Set the value field of libsql
Example
Via Builder
use anyhow::Result;
use opendal::services::Libsql;
use opendal::Operator;
#[tokio::main]
async fn main() -> Result<()> {
let mut builder = Libsql::default();
builder.root("/");
builder.connection_string("https://example.com/db");
builder.auth_token("secret");
builder.table("your_table");
// key field type in the table should be compatible with Rust's &str like text
builder.key_field("key");
// value field type in the table should be compatible with Rust's Vec<u8> like bytea
builder.value_field("value");
let op = Operator::new(builder)?.finish();
Ok(())
}
Via Config
- Rust
- Node.js
- Python
use anyhow::Result;
use opendal::Operator;
use opendal::Scheme;
use std::collections::HashMap;
#[tokio::main]
async fn main() -> Result<()> {
let mut map = HashMap::new();
map.insert("root".to_string(), "/".to_string());
map.insert("connection_string".to_string(), "https://example.com/db".to_string());
map.insert("auth_token".to_string(), "secret".to_string());
map.insert("table".to_string(), "your_table".to_string());
map.insert("key_field".to_string(), "key".to_string());
map.insert("value_field".to_string(), "value".to_string());
let op: Operator = Operator::via_map(Scheme::Libsql, map)?;
Ok(())
}
import { Operator } from "opendal";
async function main() {
const op = new Operator("libsql", {
root: "/",
connection_string: "https://example.com/db",
auth_token: "secret",
table: "your_table",
key_field: "key",
value_field: "value",
});
}
import opendal
op = opendal.Operator("libsql",
root="/",
connection_string="https://example.com/db",
auth_token="secret",
table="your_table",
key_field="key",
value_field="value"
)