D1
D1 services 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
token
: Set the token of cloudflare apiaccount_id
: Set the account id of cloudflare apidatabase_id
: Set the database id of cloudflare apitable
: Set the table of D1 Databasekey_field
: Set the key field of D1 Databasevalue_field
: Set the value field of D1 Database
Example
Via Builder
use anyhow::Result;
use opendal::services::D1;
use opendal::Operator;
#[tokio::main]
async fn main() -> Result<()> {
let mut builder = D1::default();
builder
.token("token")
.account_id("account_id")
.database_id("database_id")
.table("table")
.key_field("key_field")
.value_field("value_field");
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("token".to_string(), "token".to_string());
map.insert("account_id".to_string(), "account_id".to_string());
map.insert("database_id".to_string(), "database_id".to_string());
map.insert("table".to_string(), "table".to_string());
map.insert("key_field".to_string(), "key_field".to_string());
map.insert("value_field".to_string(), "value_field".to_string());
let op: Operator = Operator::via_map(Scheme::D1, map)?;
Ok(())
}
import { Operator } from "opendal";
async function main() {
const config = {
token: "token",
account_id: "account_id",
database_id: "database_id",
table: "table",
key_field: "key_field",
value_field: "value_field"
};
const op = new Operator("d1", config);
}
import opendal
config = {
"token": "token",
"account_id": "account_id",
"database_id": "database_id",
"table": "table",
"key_field": "key_field",
"value_field": "value_field"
}
op = opendal.Operator("d1", **config)