Ejemplo n.º 1
0
    def createEngine(self):
        _psql = get_config_db_psql()
        if _psql == None:
            logging.error("PSQL not configed.")
            reutrn None

        db_string = "postgresql+psycopg2://%s:%s@%s/%s" % (self.dbuser, 
                                                           self.dbpassword,
                                                           self.dbhost,
                                                           self.dbname)
        if self.dbengine == None:
            self.dbengine = create_engine(db_string, echo_pool=True)
        # it will create a thread local session for every single web request
        return self.dbengine
Ejemplo n.º 2
0
    def __init__(self):

        _psql = get_config_db_psql()
        if _psql == None:
            logging.error("PSQL not configed.")
            reutrn
            
        DB_NAME = _psql.get("db_name")
        DB_PASS = _psql.get("db_pass")
        DB_USER = _psql.get("db_user")
        DB_HOST = _psql.get("db_host")

        self.dbhost = DB_HOST
        self.dbname = DB_NAME
        self.dbuser = DB_USER
        self.dbpassword = DB_PASS

        super(SqlInstance, self).__init__()
        return