Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 

Repository files navigation

UnQLite.rs

This is a pure Rust port of UnQLite, an embedded, transactional, NoSQL database engine. This project aims to provide a safe and idiomatic Rust an alternative to the original C library.

Note: This is a work in progress and is not yet feature-complete. The core functionality is in place, but advanced features like cursors and full transaction support are still under development.

Features

  • Embedded, Zero-Configuration: No need for a separate server process. The database is stored in a single file.
  • Transactional: ACID-compliant transactions ensure data integrity.
  • Key/Value Store: A simple and fast key-value store.
  • Document Store: Store and retrieve JSON documents.

Usage

First, add this to your Cargo.toml:

[dependencies]
unqlite-rs = { git = "https://github.com/symisc/unqlite" }
serde_json = "1.0"

Key/Value Store Example

use unqlite_rs::Database;

fn main() -> std::io::Result<()> {
    let mut db = Database::open_os("test_kv.db".as_ref())?;

    let key = b"hello";
    let value = b"world";

    // Store a key-value pair
    db.kv_store(key, value)?;
    db.commit()?;

    // Fetch the value
    let fetched = db.kv_fetch(key)?.unwrap();
    assert_eq!(fetched, value);

    // Delete the key
    db.kv_delete(key)?;
    db.commit()?;

    Ok(())
}

Document Store Example

use unqlite_rs::Database;
use serde_json::json;

fn main() -> std::io::Result<()> {
    let mut db = Database::open_os("test_doc.db".as_ref())?;

    let key = b"user:123";
    let doc = json!({
        "name": "Jules",
        "email": "jules@example.com",
        "is_admin": true
    });

    // Store a document
    db.doc_store(key, &doc)?;
    db.commit()?;

    // Fetch the document
    let fetched = db.doc_fetch(key)?.unwrap();
    assert_eq!(fetched, doc);

    Ok(())
}

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages