Question: I am looking for a lightweight, reliable and fast key/value database for storing binary data. Simple without server. Most of popular key/value databases like CDB and BerkeleyDB does not natively store `BLOB`. What can be the best choice that I missed?

My current choice is SQLite, but it is too advanced for my simple usage.

Answer: 
As it was previously pointed out, BerkeleyDB does support opaque values and keys, but I would suggest a better alternative: LevelDB.

**LevelDB:**

Google is your friend :), so much so that they even provide you with an embedded database: [A fast and lightweight key/value database library by Google.](https://github.com/google/leveldb)

**Features:**

* Keys and values are arbitrary byte arrays.
* Data is stored sorted by key.
* Callers can provide a custom comparison function to override the sort order.
* The basic operations are Put(key,value), Get(key), Delete(key).
* Multiple changes can be made in one atomic batch.
* Users can create a transient snapshot to get a consistent view of data.
* Forward and backward iteration is supported over the data.
* Data is automatically compressed using the Snappy compression library.
* External activity (file system operations etc.) is relayed through a virtual interface so users can customize the operating system interactions.
* Detailed documentation about how to use the library is included with the source code.
Using sqlite is now straightforward with the new functions readfile(X) and writefile(X,Y) which are available since 2014-06. For example to save a blob in the database from a file and extract it again

```
     CREATE TABLE images(name TEXT, type TEXT, img BLOB);
     INSERT INTO images(name,type,img) VALUES('icon','jpeg',readfile('icon.jpg'));
     SELECT writefile('icon-copy2.jpg',img) FROM images WHERE name='icon';

```

see <https://www.sqlite.org/cli.html> "File I/O Functions"