Added a test to check whether a connection is already open.
I'd like to add something like this, but am worried about breaking too many people's code... I'll look into a similar patch.
 9e76c999868197a4911fa2fa457c50ab42431ff1
 Thanks!
 FYI: this did break our code like you mentioned above. I can work around it in our codebase but I expect this caused problems for a lot of people; is there any more robust way of doing this? Just run `database.get_conn()` which will only open a connection if the DB is closed.
Most importantly the check prevents from leaking database connections,
which can be disasterous when using connection pools.

Moreover it allows one to catch errors in the code which were caused
by not using database.connect() / database.close() properly.
