import dataset
class db(object):
_db_connection = None
_db_cur = None
def __init__(self):
self._db_connection = dataset.connect(path_to_database)
def __del__(self):
self._db_connection.executable.close()
In the code above, I create a class to connect to an existing database on AWS. Is there a way I can check if connection is already open and if so, return existing connection rather than open a new connection?