feat: add persy
This commit is contained in:
25
__database/persy/src/main.rs
Normal file
25
__database/persy/src/main.rs
Normal file
@@ -0,0 +1,25 @@
|
||||
use persy::{Persy, Config};
|
||||
use std::path::PathBuf;
|
||||
|
||||
fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
let file = "./storage.persy";
|
||||
if !PathBuf::from(file).exists() {
|
||||
Persy::create("./storage.persy")?;
|
||||
}
|
||||
let persy = Persy::open("./storage.persy",Config::new())?;
|
||||
|
||||
let mut tx = persy.begin()?;
|
||||
|
||||
if !tx.exists_segment("seg").ok().unwrap_or(false) {
|
||||
tx.create_segment("seg")?;
|
||||
}
|
||||
|
||||
let data = vec![1;20];
|
||||
let id = tx.insert("seg", &data)?;
|
||||
println!("Persy id: {}", id);
|
||||
|
||||
let prepared = tx.prepare()?;
|
||||
prepared.commit()?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
Reference in New Issue
Block a user