Change get_shelve_database to a context manager