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: 
What makes you think BerkDB cannot store binary data? From their docs:

> 
> Key and content arguments are objects described by the datum typedef. A datum specifies a string of dsize bytes pointed to by dptr. Arbitrary binary data, as well as normal text strings, are allowed.
> 
> 
> 

Also see their [examples](http://docs.oracle.com/cd/E17076_02/html/gsg/C/usingDbt.html#databaseWrite):

```
money = 122.45;
key.data = &money;
key.size = sizeof(float);
...
ret = my_database->put(my_database, NULL, &key, &data, DB_NOOVERWRITE);

```
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"