Disambiguate dual use of 'attribute'.
Start refactoring sqlite connections.

The sqlite connection handling code is...laughable.  This is just one
small step toward making it actually work with threads.