Loads the result from the given database
183828
def load(self, cachedir=None, cfgstr=None, fpath=None, verbose=None,
             quiet=QUIET, ignore_keys=None):
        
        if verbose is None:
            verbose = getattr(self, 'verbose', VERBOSE)
        if fpath is None:
            fpath = self.get_fpath(cachedir, cfgstr=cfgstr)
        if verbose:
            print('[Cachable] cache tryload: %r' % (basename(fpath),))
        try:
            self._unsafe_load(fpath, ignore_keys)
            if verbose:
                print('... self cache hit: %r' % (basename(fpath),))
        except ValueError as ex:
            import utool as ut
            msg = '[!Cachable] Cachable(%s) is likely corrupt' % (self.get_cfgstr())
            print('CORRUPT fpath = %s' % (fpath,))
            ut.printex(ex, msg, iswarning=True)
            raise
        #except BadZipFile as ex:
        except zipfile.error as ex:
            import utool as ut
            msg = '[!Cachable] Cachable(%s) has bad zipfile' % (self.get_cfgstr())
            print('CORRUPT fpath = %s' % (fpath,))
            ut.printex(ex, msg, iswarning=True)
            raise
            #if exists(fpath):
            #    #print('[Cachable] Removing corrupted file: %r' % fpath)
            #    #os.remove(fpath)
            #    raise hsexcept.HotsNeedsRecomputeError(msg)
            #else:
            #    raise Exception(msg)
        except IOError as ex:
            import utool as ut
            if not exists(fpath):
                msg = '... self cache miss: %r' % (basename(fpath),)
                if verbose:
                    print(msg)
                raise
            print('CORRUPT fpath = %s' % (fpath,))
            msg = '[!Cachable] Cachable(%s) is corrupt' % (self.get_cfgstr())
            ut.printex(ex, msg, iswarning=True)
            raise
        except Exception as ex:
            import utool as ut
            ut.printex(ex, 'unknown exception while loading query result')
            raise
142657
protected function load()
    {
        if ($this->btTable) {
            if ($this->btCacheBlockRecord && $this->btCachedBlockRecord && Config::get('concrete.cache.blocks')) {
                $this->record = unserialize(base64_decode($this->btCachedBlockRecord));
            } else {
                $this->record = new BlockRecord($this->btTable);
                $this->record->bID = $this->bID;
                $this->record->Load('bID=' . $this->bID);
                if ($this->btCacheBlockRecord && Config::get('concrete.cache.blocks')) {
                    // this is the first time we're loading
                    $record = base64_encode(serialize($this->record));
                    $db = Database::connection();
                    $db->Execute('update Blocks set btCachedBlockRecord = ? where bID = ?', [$record, $this->bID]);
                }
            }
        }

        $event = new \Symfony\Component\EventDispatcher\GenericEvent();
        $event->setArgument('record', $this->record);
        $event->setArgument('btHandle', $this->btHandle);
        $event->setArgument('bID', $this->bID);
        $ret = Events::dispatch('on_block_load', $event);
        $this->record = $ret->getArgument('record');

        if (is_object($this->record)) {
            foreach ($this->record as $key => $value) {
                $this->{$key} = $value;
                $this->set($key, $value);
            }
        }
    }
939620
def _load(self, event):
        
        if not event.data:
            return

        context = self.context()
        schema = self.schema()
        dbname = schema.dbname()
        clean = {}

        for col, value in event.data.items():
            try:
                model_dbname, col_name = col.split('.')
            except ValueError:
                col_name = col
                model_dbname = dbname

            # make sure the value we're setting is specific to this model
            try:
                column = schema.column(col_name)
            except orb.errors.ColumnNotFound:
                column = None

            if model_dbname != dbname or (column in clean and isinstance(clean[column], Model)):
                continue

            # look for preloaded reverse lookups and pipes
            elif not column:
                self.__preload[col_name] = value

            # extract the value from the database
            else:
                value = column.dbRestore(value, context=context)
                clean[column] = value

        # update the local values
        with WriteLocker(self.__dataLock):
            for col, val in clean.items():
                default = val if not isinstance(val, dict) else val.copy()
                self.__values[col.name()] = (default, val)
                self.__loaded.add(col)

        if self.processEvent(event):
            self.onLoad(event)
1063846
def load(self):
        """"""
        retries = 1
        while True:
            assert self.database is None
            assert self.cursor is None
            assert self.inserts == 0
            empty = not os.path.exists(self.state_file)
            self.database = sqlite3.connect(self.state_file)
            self.cursor = self.database.cursor()

            # Try loading once to check that the file is indeed a database
            # and reformat it if it is not.
            try:
                self._prepare_db(empty=empty)
                return
            except sqlite3.DatabaseError:
                self.cursor.close()
                self.database.close()
                self.database = None
                self.cursor = None
                self.inserts = 0
                if retries > 0:
                    os.unlink(self.state_file)
                    retries -= 1
                else:
                    raise
368577
def _load(self):
        
        if self.dbfile is not None:
            with open(self.dbfile, 'r') as f:
                self._db = json.loads(f.read())
        else:
            self._db = {}
842128
public function execute()
    {
        try {
            $sql = $this->prepared_sql;

            foreach ($this->param_list as $placeholder => $param) {
                if (strpos($this->prepared_sql, $placeholder) === false) {
                    throw new DatabaseException(__METHOD__ . " missing bound placeholder: $placeholder in sql $this->prepared_sql", MySQL::ERR_CONN, MySQL::SEVERITY_LOG, __FILE__, __LINE__);
                }


                $t = (isset($this->type_list[$placeholder]) ? $this->type_list[$placeholder] : 999999);

                switch ($t) {
                    case self::TYPE_BLOB:
                    case self::TYPE_STRING:
                        $val = "'" . mysql_real_escape_string($param, $this->_db->db) . "'";
                        break;
                    case self::TYPE_INT:
                    case self::TYPE_BOOL:
                        $val = (int)$param;
                        break;
                    case self::TYPE_FLOAT:
                        $val = (float)$param;
                        break;
                    case self::TYPE_NULL:
                        $val = 'NULL';
                        break;
                    default:
                        $val = "'" . (mysql_real_escape_string($param, $this->_db->db)) . "'";
                        break;
                }
                $sql = str_replace($placeholder, $val, $sql);
            }
        } catch (DatabaseException $e) {
            throw $e;
        }

        unset($t, $val, $param);

        /**
         * set the sql for debugging purposes
         */
        $this->sql = $sql;

        /**
         * query the database
         */
        $this->res = $this->_db->query($sql);

        if (!$this->res) return false;

        return $this;
    }
714571
public void loadDatabaseProperties()
    {
        if (this.getProperty(STARTING_ID) != null)
            return; // Already read (This value will be cached in the environment database cache)
        int iStartID = 1;
        /* This code works, but I prefer to use the DatabaseInfo record.
        try {
            Statement queryStatement = this.getJDBCConnection().createStatement();
    
            String strSQL = "select StartID from DatabaseInfo where ID=1;";
            queryStatement.execute(strSQL);
            
            ResultSet resultset = queryStatement.getResultSet();
            boolean more = resultset.next();
            if (more)
            {
                iStartID = resultset.getInt(1);
            }
            resultset.close();
            queryStatement.close();
        } catch (SQLException e) {
            // Ignore table not found error.
        }
        */
    	if ((this.getDatabaseType() & (DBConstants.SHARED_DATA | DBConstants.USER_DATA)) != DBConstants.SHARED_DATA)
    		return;		// DatabaseInfo would only exist for shared databases

    	RecordOwner recordOwner = null; // ((BaseApplication)this.getDatabaseOwner().getEnvironment().getDefaultApplication()).getMainTask().; // For now
        DatabaseInfo recDatabaseInfo = new DatabaseInfo();
        recDatabaseInfo.setTable(this.doMakeTable(recDatabaseInfo));    // This makes a jdbc table
        String dbName = this.getDatabaseName(true);
        if (dbName.endsWith(SHARED_SUFFIX))
        	dbName = dbName.substring(0, dbName.length() - SHARED_SUFFIX.length());	// Always
        else if (dbName.endsWith(USER_SUFFIX))
        	dbName = dbName.substring(0, dbName.length() - USER_SUFFIX.length());	// Never
        recDatabaseInfo.setDatabaseName(dbName);

        int iOldOpenMode = recDatabaseInfo.getOpenMode();
        //x recDatabaseInfo.setOpenMode(recDatabaseInfo.getOpenMode() | DBConstants.OPEN_DONT_CREATE); // Removed 

        recDatabaseInfo.init(recordOwner);

        recDatabaseInfo.setOpenMode(iOldOpenMode);
        
        if (recDatabaseInfo.getEditMode() == DBConstants.EDIT_CURRENT)
        {
            iStartID = (int)recDatabaseInfo.getField(DatabaseInfo.START_ID).getValue();
            if (!recDatabaseInfo.getField(DatabaseInfo.END_ID).isNull())
                this.addDatabaseProperty(ENDING_ID, Integer.toString((int)recDatabaseInfo.getField(DatabaseInfo.END_ID).getValue()));
            if (!recDatabaseInfo.getField(DatabaseInfo.BASE_DATABASE).isNull())
                this.addDatabaseProperty(BaseDatabase.BASE_DATABASE, recDatabaseInfo.getField(DatabaseInfo.BASE_DATABASE).toString());
        }
        if (iStartID <= 0)
            iStartID = 1;
        recDatabaseInfo.free();
        this.addDatabaseProperty(STARTING_ID, Integer.toString(iStartID));
        
        if (m_databaseBase == null) // Always
            if (this.getProperty(BASE_DATABASE) != null)
        {
            Map<String,Object> properties = new HashMap<String,Object>();
            properties.putAll(this.getProperties());
            properties.remove(BASE_DATABASE);
            properties.put(BASE_DATABASE_JDBC_DRIVER, properties.remove(SQLParams.JDBC_DRIVER_PARAM));
            properties.put(DBConstants.DB_USER_PREFIX, DBConstants.BLANK);
            properties.remove(DBConstants.SYSTEM_NAME);
            properties.put(DBConstants.MODE, DBConstants.BLANK);
            m_databaseBase = (BaseDatabase)m_databaseOwner.getDatabase(this.getProperty(BASE_DATABASE), this.getDatabaseType() & DBConstants.TABLE_MASK, properties);
        }
    }
1188070
private function loadDatabaseConnection()
    {
        /**
         * Setup for 'illuminate/database'
         */
        $capsule = new Manager;
        $capsule->addConnection(config('database.database_connection.mysql'));
        $capsule->setAsGlobal();
        $capsule->bootEloquent();
        $capsule::connection();
    }
321188
def query(database, query, **client_args):
    '''
    
    '''
    client = _client(**client_args)
    _result = client.query(query, database=database)

    if isinstance(_result, collections.Sequence):
        return [_pull_query_results(_query_result) for _query_result in _result if _query_result]
    return [_pull_query_results(_result) if _result else {}]
18743
def load_db(file, db, verbose=True):
    
    db_data = json.load(file, verbose=verbose)
    return _load(db_data, db)
443173
function (dbname, callback) {
    var executeDB = load('db');
    this.internals.argv._.push(dbname);
    this.internals.mode = 'create';
    return Promise.fromCallback(
      function (callback) {
        executeDB(this.internals, this.config, callback);
      }.bind(this)
    ).asCallback(callback);
  }
678994
public function loadAssoc()
	{
		// Initialise variables
		$return = null;

		// Execute the query
		if (!$this->execute())
		{
			return null;
		}

		// Get the first row from the result set as an associative array
		if ($row = $this->fetchAssoc())
		{
			$return = $row;
		}

		// Free up system resources and return
		$this->freeResult();

		return $return;
	}
1044096
def _read_from_sql(self, request, db_name):
        
        with contextlib.closing(sqlite3.connect("{}.db".format(db_name))) as con:
            return sql.read_sql(sql=request, con=con)
1011167
def get(cls, database, conditions=""):
        
        assert isinstance(database, Database), "database must be database.Database class instance"
        assert isinstance(conditions, string_types), "conditions must be a string"
        if conditions:
            conditions += " AND"
        field_names = ','.join(cls.fields())
        return database.select("SELECT %s FROM %s WHERE %s database='%s'" %
                               (field_names,  cls.table_name(), conditions, database.db_name), model_class=cls)
579755
public function load()
    {
        $data = [];

        $settings = $this->database->select('SELECT * FROM '.$this->table);

        foreach ($settings as $setting) {
            $id = $setting->id;
            $value = $setting->value;

            $decoded = json_decode($value, 1, 512);
            if (is_array($decoded)) {
                $value = $decoded;
            }

            Arr::set($data, $id, $value);
        }

        return $data;
    }
1025282
function (database, callback) {
        var s = this,
            querier = s._querier;
        querier.connect();
        async.waterfall([
            function (callback) {
                querier.showTables(database, function (err, tables) {
                    callback(err, tables);
                });
            },
            function (tables, callback) {
                var tableNames = s._parseTableNames(tables);
                async.map(tableNames, function (table, callback) {
                    querier.selectKeyColumnUsage(database, table, function (err, data) {
                        callback(err, {
                            name: table,
                            keyColumnUsage: s._parseTableKeyColumnUsageData(data)
                        });
                    });
                }, callback);
            },
            function (data, callback) {
                var database = {};
                data.forEach(function (data) {
                    database[data.name] = data.keyColumnUsage;
                });
                callback(null, database);
            }
        ], function (err, result) {
            querier.disconnect();
            callback(err, result);
        });
        return s;
    }
1044090
public function loadResult($params=array()) {
		
		$this->openConnection();
		
		$res = NULL;

		try {

			$stat = $this->handler->prepare($this->query);
			$stat->execute((array)$params);
			
			// logger
			$count = $this->handler->query('SELECT FOUND_ROWS()')->fetchColumn();
			$this->logParamQuery($this->query, $count, $params);
			$res = $stat->fetch(\PDO::FETCH_COLUMN);	
		
		} catch (\PDOException $e) {

			$this->handleException($e, $params);

		}
		
		$stat->closeCursor();

		return $res;
		
	}