redmine6444: Support sqlite, rework database promises

This is the portion of @markburgess's development branch that deals with sqlite and database promises, as reindented and rebased onto master by @ediosyncratic.