Building a key/value store using C++

By Steve Claridge on 2022-10-03.

I'm building a key/value store in C++ that uses SQLite for storage and has a simple command-line interface for storing and retrieving values. I want to use this to store often-used commands/snippets/passwords or anything else I need quickly and often when I'm using a terminal.


Not sure what I'm calling this yet but lets assume its called kv for now.

  • kv -p <key> <value> adds or replaces key and stores against it
  • kv <key> retrieves the value stored for or returns nothing is no key found
  • kv -d <key> deletes the given key
  • kv -list all keys that currently exist in alphabetical order
  • kv -list <search-term> lists all keys that start with the search term in alphabetical order
  • kv -help shows a help page
  • Must allow piping of values e.g. `history | grep < kv '
  • SQLite DB file should be stored in standard location for host OS
  • Keys with spaces are NOT supported
  • Values with spaces ARE supported by enclosing in double quotes
  • Keys are NOT case sensitive
  • Keys can include punctuation

Non-functional requirements

I'm using this project as a way to get back into C++ after a long time in Java-land. So want to use the latest, common and standard tools:

  • Use newish version of C++
  • Use standard code-formatting tools
  • Use GooleTest
  • Use Valgrind