Crates.io | bb8-surrealdb |
lib.rs | bb8-surrealdb |
version | 0.1.3 |
source | src |
created_at | 2022-10-27 11:18:04.894811 |
updated_at | 2022-11-09 01:57:46.831377 |
description | SurrealDB driver for bb8 based on the surrealdb crate |
homepage | |
repository | https://github.com/blakeanedved/bb8-surrealdb |
max_upload_size | |
id | 699073 |
size | 6,761 |
SurrealDB support for bb8 based on the surrealdb crate.
Make sure to add bb8
and bb8-surrealdb
to your Cargo.toml
, like:
[dependencies]
bb8 = "0.8"
bb8-surrealdb = "0.1.2"
surrealdb = "1.0.0-beta.8"
use bb8::Pool;
use bb8_surrealdb::SurrealdbConnectionManager;
use surrealdb::Session;
use futures_util::join_all;
#[tokio::main]
async fn main() {
let pool = Pool::builder()
.max_size(5)
.build(
SurrealdbConnectionManager::tikv(
"localhost:2379",
Session::for_kv().with_ns("test").with_db("test")
).await
)
.await
.unwrap();
for _i in 0..10 {
let pool = pool.clone();
handles.push(tokio::spawn(async move {
let conn = pool.get().await.unwrap();
conn.execute("SELECT * from user;", None, false).await.unwrap();
}))
}
join_all(handles).await;
}
This crate is really only useful if compiling with the tikv
feature, as you cannot have multiple instances of a connection to an in memory embedded database or multiple instances of a connection to a file based store due to file locks. This feature has not been included by default to allow compilation as the surreal crate with the tikv feature does not compile on windows, and only compiles on other platforms if GCC 8 specifically is installed.
bb8-surrealdb
is primarily distributed under the terms of the MIT license.
See LICENSE for details.