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.
Merge pull request #23 from breber/crash

Prevent crash when trying to open database