Safely opens the database object associated with the identifier.
Returns a smart pointer to the opened object if successful or throws an exception in other case.
openMode must be one of the following:
Can throw one of the following exceptions: