#database #key-value-store #db #kv #pickledb


A lightweight and simple key-value store written in Rust, heavily inspired by Python’s PickleDB

5 releases (3 breaking)

✓ Uses Rust 2018 edition

0.4.1 Mar 29, 2020
0.4.0 May 15, 2019
0.3.0 Feb 5, 2019
0.2.0 Jan 23, 2019
0.1.0 Jan 16, 2019

#5 in Database implementations

Download history 64/week @ 2020-01-25 159/week @ 2020-02-01 298/week @ 2020-02-08 146/week @ 2020-02-15 189/week @ 2020-02-22 225/week @ 2020-02-29 181/week @ 2020-03-07 130/week @ 2020-03-14 179/week @ 2020-03-21 50/week @ 2020-03-28 109/week @ 2020-04-04 71/week @ 2020-04-11 90/week @ 2020-04-18 172/week @ 2020-04-25 173/week @ 2020-05-02 221/week @ 2020-05-09

631 downloads per month
Used in 10 crates (8 directly)

MIT license

813 lines


Build Status Crate API

PickleDB is a lightweight and simple key-value store written in Rust, heavily inspired by Python's PickleDB

PickleDB is fun and easy to use

use pickledb::{PickleDb, PickleDbDumpPolicy, SerializationMethod};

fn main() {

    // create a new DB with AutoDump (meaning every change is written to the file)
    // and with Json serialization (meaning DB will be dumped to file as a Json object)
    let mut db = PickleDb::new("example.db", PickleDbDumpPolicy::AutoDump, SerializationMethod::Json);

    // set the value 100 to the key 'key1'
    db.set("key1", &100).unwrap();

    // print the value of key1
    println!("The value of key1 is: {}", db.get::<i32>("key1").unwrap());

    // load the DB from the same file
    let db2 = PickleDb::load("example.db", PickleDbDumpPolicy::DumpUponRequest, SerializationMethod::Json).unwrap();

    // print the value of key1
    println!("The value of key1 as loaded from file is: {}", db2.get::<i32>("key1").unwrap());


This crate works with Cargo and can be found in crates.io Add this to your Cargo.toml:

pickledb = "0.4.1"


All documentation for this crate can be found in docs.rs


There are currently two examples shipped with PickleDB:

  • Hello World which shows the basic usage of PickleDB: create a new DB, load a DB from file, get/set key-value pairs of different types, and more
  • Lists which shows how to use lists in PickleDB: create new lists, add/remove items from lists, retrieve items from lists, remove lists, and more


Version 0.4.1

  • Bump up dependencies versions to fix vulnerabilities found in few of them

Version 0.4.0

  • Changed all doc tests from ignore to no_run so generated docs don't contain untested warnings
  • Changed both instances of lextend to take iterators of references rather than a slice of values
  • Fixed bug in load_test()
  • Fixed rustfmt and clippy warnings
  • Added examples to Cargo.toml to allow them to be run via Cargo

Version 0.3.0

  • Added new serialization options. Now PickleDB supports JSON, Bincode, YAML and CBOR serializations
  • Added proper error handling (Issue #3)
  • Use Path and PathBuf instead of strings to describe DB paths
  • Better organization of the code

Version 0.2.0


~49K SLoC