Load :class:`mongomock.database.Database` from a local file.

    :param file: file path.
    :param db: instance of :class:`mongomock.database.Database`.
    :param verbose: bool, toggle on log.
    :return: loaded db.
18743
def load_db(file, db, verbose=True):
    
    db_data = json.load(file, verbose=verbose)
    return _load(db_data, db)
658418
def from_file(cls, db_file=ALL_SETS_PATH):
        
        if callable(getattr(db_file, 'read', None)):
            return cls(json.load(db_file))

        with io.open(db_file, encoding='utf8') as inp:
            return cls(json.load(inp))
178982
function load(filename) {

  return function(cb) {
    var file = path.join(process.cwd(), filename)
      , json = require(file)
      , model = exports[json.table]
      , rows = json.rows;

    console.log('Loading', file);

    run();
    function run() {
      var row = rows.shift();
      if(row !== undefined) {
        model.create(row, function(err) {
          if(err) {
            cb(err);
          } else {
            run();
          }
        });
      } else {
        cb();
      }
    }
  };
}
526276
def _load(db_data, db):
    
    if db.name != db_data["name"]:
        raise ValueError("dbname doesn't matches! Maybe wrong database data.")

    db.__init__(client=db._client, name=db.name)
    for col_name, col_data in iteritems(db_data["_collections"]):
        collection = db.get_collection(col_name)
        collection._documents = col_data["_documents"]
        collection._uniques = col_data["_uniques"]
        db._collections[col_name] = collection

    return db
1301514
def read_file(path, verbose=False):
    
    for filehandle in filehandles(path, verbose=verbose):
        return CTfile.load(filehandle)
1238362
function loadFile(file, db, callback) { 
    callback = callback || function() {};
    
    if (file.substr(0, 1) !== '/') {
        var parentPath = module.parent.filename.split('/');
        parentPath.pop();
        file = parentPath.join('/') + '/' + file;
    }
    
    load(require(file), db, callback);
}
163286
public OWLOntology loadOntologyFromFile(File file) throws OWLIOException
    {
        try
        {
            return owlOntologyManager.loadOntologyFromOntologyDocument(file);
        } catch (OWLOntologyCreationException ex)
        {
            throw new OWLIOException(ioErrorMsg, ex);
        }
    }
517771
def loadRecord(self, domain, rtype, callback=None, errback=None):
        
        rec = Record(self, domain, rtype)
        return rec.load(callback=callback, errback=errback)
427523
def make(self, cmd_args, db_args):
        '''
        
        '''
        with NamedTemporaryFile(delete=True) as f:
            format_file = f.name + '.bcp-format'
        format_args = cmd_args + ['format', NULL_FILE, '-c', '-f', format_file, '-t,'] + db_args
        _run_cmd(format_args)
        self.load(format_file)
        return format_file
865756
def from_statements_file(cls, file: str):
        

        with open(file, "rb") as f:
            sts = pickle.load(f)

        return cls.from_statements(sts)
1071393
def load_all
      return unless @file
      return if @loaded_objects >= @available_objects
      log.debug "Loading entire database: #{@file} ..."
      objects = []

      all_disk_objects.sort_by(&:size).each do |path|
        obj = @serializer.deserialize(path, true)
        objects << obj if obj
      end

      objects.each do |obj|
        put(obj.path, obj)
      end

      @loaded_objects += objects.size
      log.debug "Loaded database (file='#{@file}' count=#{objects.size} total=#{@available_objects})"
    end
917728
def load_from_db(self, cache=False):
        """"""
        a = {}
        db_prefs = {p.preference.identifier(): p for p in self.queryset}
        for preference in self.registry.preferences():
            try:
                db_pref = db_prefs[preference.identifier()]
            except KeyError:
                db_pref = self.create_db_pref(
                    section=preference.section.name,
                    name=preference.name,
                    value=preference.get('default'))
            else:
                # cache if create_db_pref() hasn't already done so
                if cache:
                    self.to_cache(db_pref)

            a[preference.identifier()] = db_pref.value

        return a
1096198
def load(dbname):
    
    db = Database(dbname)

    # Get the name of the objects
    tables = get_table_list(db.cur)

    # Create a Trace instance for each object
    chains = 0
    for name in tables:
        db._traces[name] = Trace(name=name, db=db)
        db._traces[name]._shape = get_shape(db.cur, name)
        setattr(db, name, db._traces[name])
        db.cur.execute('SELECT MAX(trace) FROM [%s]' % name)
        chains = max(chains, db.cur.fetchall()[0][0] + 1)

    db.chains = chains
    db.trace_names = chains * [tables, ]
    db._state_ = {}
    return db
1203195
function loadDir(dir, db, callback) {
    callback = callback || function() {};
    
    //Get the absolute dir path if a relative path was given
    if (dir.substr(0, 1) !== '/') {
        var parentPath = module.parent.filename.split('/');
        parentPath.pop();
        dir = parentPath.join('/') + '/' + dir;
    }
    
    //Load each file in directory
    fs.readdir(dir, function(err, files){
        if (err) return callback(err);
        
        var iterator = function(file, next){
            loadFile(dir + '/' + file, db, next);
        };
        async.forEach(files, iterator, callback);
    });
}
318878
def _load(self, reload=False):
        
        if self.autoreload or reload:
            # First, we load from YAML, failing if syntax errors are found
            options = self.storage_options or {}
            if hasattr(self.path, 'path') or hasattr(self.path, 'read'):
                file_open = self.path
                self.path = make_path_posix(
                    getattr(self.path, 'path',
                            getattr(self.path, 'name', 'file')))
            else:
                file_open = open_files(self.path, mode='rb', **options)
                assert len(file_open) == 1
                file_open = file_open[0]
            self._dir = get_dir(self.path)

            with file_open as f:
                text = f.read().decode()
            if "!template " in text:
                logger.warning("Use of '!template' deprecated - fixing")
                text = text.replace('!template ', '')
            self.parse(text)
1146816
def db_use_local_file(self, arg, filename=None):
        '''  '''
        # interactive = False  # Never used
        if filename is None:
            # interactive = True  # Never used
            filename = raw_input('Enter the filename of the local SQLLite '
                                 'database you would like to use '
                                 '[default=participants.db]: ')
            if filename == '':
                filename = 'participants.db'
        base_url = "sqlite:///" + filename
        self.config.set("Database Parameters", "database_url", base_url)
        print "Updated database setting (database_url): \n\t", \
        self.config.get("Database Parameters", "database_url")
        if self.server.is_server_running() == 'yes':
            self.server_restart()
987588
def load_sqlite(self, db, query=None, table=None, cls=None,
                    column_map=None):
        """"""
        if column_map is None:
            column_map = {}
        db_path = self.profile_path(db, must_exist=True)

        def obj_factory(cursor, row):
            dict_ = {}
            for idx, col in enumerate(cursor.description):
                new_name = column_map.get(col[0], col[0])
                dict_[new_name] = row[idx]
            return cls(**dict_)

        con = sqlite3.connect(str(db_path))
        con.row_factory = obj_factory
        cursor = con.cursor()
        if not query:
            columns = [f.name for f in attr.fields(cls)]
            for k, v in column_map.items():
                columns[columns.index(v)] = k
            query = 'SELECT %s FROM %s' % (','.join(columns), table)
        cursor.execute(query)
        while True:
            item = cursor.fetchone()
            if item is None:
                break
            yield item
        con.close()