gpg: Move sqlite helper functions into their own file.