handle case when db is not opened correctly

As @kevinswiber mentioned in #41 we should probably handle a db that's not opened correctly a bit better. This one takes care of that.