def db(self, role='replica', db_name=None): if not hasattr(self, '_db'): self._db = {} name = db_name or self.db_names.get(role) if name not in self._db: self._db[name] = DatabaseConnections.connection(name) return self._db[name]
def query(sql=None, filename=None, extract=None, db=None, **kwargs): if db is None: raise argparse.ArgumentError('You must provide a database name') kwargs['stack'] = stack_marker(inspect.stack()) filename = filename or extract if filename and not filename.startswith('/'): filename = os.path.join(os.environ['PWD'], filename) if 'where' not in kwargs and 'params' in kwargs: kwargs['where'] = kwargs['params'] return DatabaseAdapter(DatabaseConnections.connection(db), None).raw_query(sql=sql, filename=filename, **kwargs)
def wrapper(*args, **kwargs): if DatabaseConnections.connection( 'jardin_test').db_config.scheme in schemes: return func(*args, **kwargs)
def __init__(self, db): self.connection = DatabaseConnections.connection(db)
def reset_session(): DatabaseConnections.shuffle_connections()