Backend SQLite database utilites.

Functions should be used only by the higher-level database module.