Check if database exists before fetching value.