I have 3 classes in my project. One is a DB class where I have the DB connection for my project, which looks like this.
class DB:
def __init__(self):
self.createConnection()
def createConnection(self):
db = DataBase(
[config.endpoint],
http_auth=(config.username, config.password),
scheme="https"
)
self.__db = db
Now in other classes I want to access and use self.__db
How can I use this? My 2nd class is a helper class:
import db
class Helper:
def connection(self):
db = db.createConnection()
self.__db = db
print(self.__db)