Add mechanism for connection to sqlite3

This currently doesn't actually do anything with the sqlite3
connection, but it does at least track it (using shared pointers and
such) to ensure that there's always one valid connection to database
and never any more.