Fix Database lock issue

Connection with SQLite is now left open during the lifetime of the
database object.