Quick and dirty port to SQLite.

  This seems functional, and the cut-down user-test succeeds.

  Might need more changes though.