(self, dbname, autocommit = 0, isolation_level = -1,
                     cache = None, connstr = None, profile = None)
return dbc.get_connection(params['isolation_level'], clist)
Load cached database connection.

        User must not store it permanently somewhere,
        as all connections will be invalidated on reset.
Load cached database connection.
Load cached database connection .
def get_database(self, dbname, autocommit = 0, isolation_level = -1,
                     cache = None, connstr = None, profile = None):
        """Load cached database connection.

        User must not store it permanently somewhere,
        as all connections will be invalidated on reset.
        """

        max_age = self.cf.getint('connection_lifetime', DEF_CONN_AGE)

        if not cache:
            cache = dbname

        params = {}
        defs = self._db_defaults.get(cache, {})
        params.update(defs)
        if isolation_level >= 0:
            params['isolation_level'] = isolation_level
        elif autocommit:
            params['isolation_level'] = 0
        elif params.get('autocommit', 0):
            params['isolation_level'] = 0
        elif not 'isolation_level' in params:
            params['isolation_level'] = skytools.I_READ_COMMITTED

        if not 'max_age' in params:
            params['max_age'] = max_age

        if cache in self.db_cache:
            dbc = self.db_cache[cache]
            if connstr is None:
                connstr = self.cf.get(dbname, '')
            if connstr:
                connstr = self.add_connect_string_profile(connstr, profile)
                dbc.check_connstr(connstr)
        else:
            if not connstr:
                connstr = self.cf.get(dbname)
            connstr = self.add_connect_string_profile(connstr, profile)

            # connstr might contain password, it is not a good idea to log it
            filtered_connstr = connstr
            pos = connstr.lower().find('password')
            if pos >= 0:
                filtered_connstr = connstr[:pos] + ' [...]'

            self.log.debug("Connect '%s' to '%s'" % (cache, filtered_connstr))
            dbc = DBCachedConn(cache, connstr, params['max_age'], setup_func = self.connection_hook)
            self.db_cache[cache] = dbc

        clist = []
        if cache in self._listen_map:
            clist = self._listen_map[cache]

        return dbc.get_connection(params['isolation_level'], clist)
def get_database ( self , dbname , autocommit = 0 , isolation_level = - 1 , cache = None , connstr = None , profile = None ) : max_age = self . cf . getint ( 'connection_lifetime' , DEF_CONN_AGE ) if not cache : cache = dbname params = { } defs = self . _db_defaults . get ( cache , { } ) params . update ( defs ) if isolation_level >= 0 : params [ 'isolation_level' ] = isolation_level elif autocommit : params [ 'isolation_level' ] = 0 elif params . get ( 'autocommit' , 0 ) : params [ 'isolation_level' ] = 0 elif not 'isolation_level' in params : params [ 'isolation_level' ] = skytools . I_READ_COMMITTED if not 'max_age' in params : params [ 'max_age' ] = max_age if cache in self . db_cache : dbc = self . db_cache [ cache ] if connstr is None : connstr = self . cf . get ( dbname , '' ) if connstr : connstr = self . add_connect_string_profile ( connstr , profile ) dbc . check_connstr ( connstr ) else : if not connstr : connstr = self . cf . get ( dbname ) connstr = self . add_connect_string_profile ( connstr , profile ) # connstr might contain password, it is not a good idea to log it filtered_connstr = connstr pos = connstr . lower ( ) . find ( 'password' ) if pos >= 0 : filtered_connstr = connstr [ : pos ] + ' [...]' self . log . debug ( "Connect '%s' to '%s'" % ( cache , filtered_connstr ) ) dbc = DBCachedConn ( cache , connstr , params [ 'max_age' ] , setup_func = self . connection_hook ) self . db_cache [ cache ] = dbc clist = [ ] if cache in self . _listen_map : clist = self . _listen_map [ cache ] return dbc . get_connection ( params [ 'isolation_level' ] , clist )