Prevent crash when trying to open database

When the database has already been opened, don't try reopening it.
Instead, just return the current reference.