Updates values in DB from fetched file
328907
public static function updateDatabase()
    {
        FileSystem::mkDir(DIR_TEMP . 'GeoIPCountryCSV');

        $file_to_extract = DIR_TEMP . 'GeoIPCountryCSV/GeoIPCountryCSV.zip';
        if (!file_exists($file_to_extract) || filemtime($file_to_extract) < NOW - 86400) {
            $f = @file_get_contents('http://geolite.maxmind.com/download/geoip/database/GeoIPCountryCSV.zip');
            if ($f === false) {
                throw new RuntimeException('Can not connect to MaxMind');
            }

            file_put_contents(DIR_TEMP . 'GeoIPCountryCSV/GeoIPCountryCSV.zip', $f);
            unset($f);
        }


        // Extract file
        $zip = new \ZipArchive;
        $zip->open($file_to_extract);
        $zip->extractTo(DIR_TEMP . 'GeoIPCountryCSV/');
        $zip->close();

        $ranges = new MaxMindGeoIpRangeEntityRepository;
        $countries = new MaxMindGeoIpCountryEntityRepository();

        // Create new tables
        $ranges->ensureDbTableExists();
        $countries->ensureDbTableExists();

        $ranges->deleteObjectCollection();
        $countries->deleteObjectCollection();

        $countries_sql = $ranges_sql = [];
        $fh = fopen(DIR_TEMP . 'GeoIPCountryCSV/GeoIPCountryWhois.csv', 'rb');

        while (($q = fgetcsv($fh, 4096, ',')) !== false) {
            if (!isset($q[4])) {
                continue;
            }

            $ranges_sql[] = '(NULL, "' . sql_prepare($q[4]) . '","' . sql_prepare($q[2]) . '","' . sql_prepare($q[3]) . '")';
            if (!isset($countries_sql[$q[4]])) {
                $countries_sql[$q[4]] = '(NULL, "' . $q[4] . '","' . sql_prepare($q[5]) . '")';
            }
        }
        fclose($fh);

        // Clean SQL works much faster and we now what values are
        q('INSERT INTO `cms_maxmind_geoip_c` VALUES ' . implode(',', $countries_sql), false);

        $q = [];
        $ql = 0;
        $so = count($ranges_sql);

        for ($i = 0; $i < $so; ++$i) {
            $l = strlen($ranges_sql[$i]);
            if ($ql + $l > 983040) {
                q('INSERT INTO `cms_maxmind_geoip_r` VALUES ' . implode(',', $q));
                $q = [];
                $ql = 0;
            }
            $q[] = $ranges_sql[$i];
            $ql += $l;
        }

        // If have anything to save
        if ($q) {
            q('INSERT INTO `cms_maxmind_geoip_r` VALUES ' . implode(',', $q));
        }

        q('OPTIMIZE TABLE `cms_maxmind_geoip_r`,`cms_maxmind_geoip_c`');

        Cacher::getInstance()->getDefaultCacher()->set('geo_ip_lmt', NOW);
    }
786903
def _todo_do_update(self, line):
        ""
        table, line = self.get_table_params(line)
        hkey, line = line.split(" ", 1)
        expected, attr = self.get_expected(line)

        if attr[0] == '-':
            op, attr = attr.split(" ", 1)
            op = op[1]
        else:
            op = "u"

        if attr[0] == '+':
            ret, attr = attr.split(" ", 1)
            ret = ret[1:]
        else:
            ret = "ALL_NEW"

        if ',' in hkey:
            hkey, rkey = hkey.split(",", 1)
        else:
            rkey = None

        item = table.new_item(hash_key=self.get_typed_key_value(table, hkey), range_key=self.get_typed_key_value(table, rkey, False))

        attr = json.loads(attr.strip())
        for name in attr.keys():
            value = attr[name]
            if isinstance(value, list):
                value = set(value)

            if op == 'a':
                item.add_attribute(name, value)
            elif op == 'd':
                item.delete_attribute(name, value)
            else:
                item.put_attribute(name, value)

        self.pprint(item)
        updated = item.save(expected_value=expected or None, return_values=ret)
        self.pprint(updated)

        if self.consumed:
            print "consumed units:", item.consumed_units
240207
def _loadDB(self):
        """"""
        if not self._validID():
            raise NotFound, self._getID()
        (sql, fields) = self._prepareSQL("SELECT")
        curs = self.cursor()
        curs.execute(sql, self._getID())
        result = curs.fetchone()
        if not result:
            curs.close()
            raise NotFound, self._getID()
        self._loadFromRow(result, fields, curs)
        curs.close()
        self._updated = time.time()
242078
private void updateFile() {

        @SuppressWarnings("unchecked")
        List<Logger> logger = (List<Logger>)m_container.getItemIds();

        for (Logger item : logger) {
            m_container.getItem(item).getItemProperty(TableColumn.File).setValue(getLogFiles(item));
        }
        resetPageBuffer();
        refreshRenderedCells();
        refreshRowCache();
    }
799037
def update(connection, force_download):
    """"""
    manager.database.update(
        connection=connection,
        force_download=force_download
    )
1241486
def update(self, iterable):
        """"""
        _lists = self._lists
        _maxes = self._maxes
        values = sorted(iterable)

        if _maxes:
            if len(values) * 4 >= self._len:
                values.extend(chain.from_iterable(_lists))
                values.sort()
                self._clear()
            else:
                _add = self.add
                for val in values:
                    _add(val)
                return

        _load = self._load
        _lists.extend(values[pos:(pos + _load)]
                      for pos in range(0, len(values), _load))
        _maxes.extend(sublist[-1] for sublist in _lists)
        self._len = len(values)
        del self._index[:]
1075956
def update_ase(db_file, identity, stdout, **key_value_pairs):
    """"""
    db_ase = ase.db.connect(db_file)

    _normalize_key_value_pairs_inplace(key_value_pairs)
    count = db_ase.update(identity, **key_value_pairs)
    stdout.write('  Updating {0} key value pairs in ASE db row id = {1}\n'
                 .format(count, identity))
    return
1278339
def _update_from_database(self):
        
        collection = JSONClientValidated('assessment',
                                         collection='AssessmentSection',
                                         runtime=self._runtime)
        self._my_map = collection.find_one({'_id': self._my_map['_id']})
910630
def update(self, id, data):
        
        self.db.execute([
            'UPDATE comments SET',
            ','.join(key + '=' + '?' for key in data),
            'WHERE id=?;'],
            list(data.values()) + [id])

        return self.get(id)
204584
public int update(SQLiteDatabase db, ContentValues values) {
        assertTable();
        return db.update(mTable, values, getSelection(), getSelectionArgs());
    }
995029
public static function update()
	{
		$results = array();

		$db = Factory::getDBO();

		/***
		 * UPGRADES FOR 1.1.0 Patch 2
		 ***/
		//see if the columns exists
		$query = 'SHOW COLUMNS FROM #__jfusion';
		$db->setQuery($query);
		$columns = $db->loadColumn();

		/**
		 * for 2.0
		 */
		$query = 'ALTER TABLE #__jfusion_sync_details CHANGE  `message`  `message` TEXT';
		$db->setQuery($query);
		$db->execute();

		$query = 'SHOW COLUMNS FROM #__jfusion';
		$db->setQuery($query);
		$columns = $db->loadColumn();

		//remove the plugin_files if it exists
		if (in_array('plugin_files', $columns)) {
			//remove the column
			$query = 'ALTER TABLE #__jfusion DROP column plugin_files';
			$db->setQuery($query);
			$db->execute();
		}

		// let's update to json
		$query = $db->getQuery(true)
			->select('params, id')
			->from('#__jfusion');

		$db->setQuery($query);
		$rows = $db->loadObjectList();
		if(!empty($rows)) {
			foreach ($rows as $row) {
				if ($row->params) {
					$params = base64_decode($row->params);
					if (strpos($params, 'a:') === 0) {
						ob_start();
						$params = unserialize($params);
						ob_end_clean();
						if (is_array($params)) {
							$params = new Registry($params);
							$row->params  = $params->toString();
							$db->updateObject('#__jfusion', $row, 'id');
						}
					}
				}
			}
		}

		/**
		 * 3.0
		 */
		//remove the plugin_files if it exists
		if (in_array('master', $columns)) {
			//remove master
			$query = 'ALTER TABLE #__jfusion DROP column master';
			$db->setQuery($query);
			$db->execute();
			//remove slave
			$query = 'ALTER TABLE #__jfusion DROP column slave';
			$db->setQuery($query);
			$db->execute();
			//remove search
			$query = 'ALTER TABLE #__jfusion DROP column search';
			$db->setQuery($query);
			$db->execute();
			//remove discussion
			$query = 'ALTER TABLE #__jfusion DROP column discussion';
			$db->setQuery($query);
			$db->execute();
		}

		//add a active column for user sync
		$query = 'SHOW COLUMNS FROM #__jfusion_sync';
		$db->setQuery($query);
		$columns = $db->loadColumn();
		if (!in_array('type', $columns)) {
			$query = 'ALTER TABLE #__jfusion_sync
					ADD COLUMN `type` VARCHAR(50) DEFAULT NULL';
			$db->setQuery($query);
			$db->execute();
		}

		//cleanup unused plugins
		$query = $db->getQuery(true)
			->select('name')
			->from('#__jfusion')
			->where('(params IS NULL OR params = ' . $db->quote('') . ' OR params = ' . $db->quote('0') . ')')
			->where('status = 0');

		$db->setQuery($query);
		$rows = $db->loadObjectList();
		if(!empty($rows)) {
			foreach ($rows as $row) {
				$query = $db->getQuery(true)
					->select('count(*)')
					->from('#__jfusion')
					->where('original_name LIKE ' . $db->quote($row->name));

				$db->setQuery($query);
				$copys = $db->loadResult();
				if (!$copys) {
					$model = new Plugin();
					$model->uninstall($row->name);
				}
			}
		}
		return true;
	}
315324
protected function updateValuesFromRequest()
    {
        $data = $this->getRequest()->isPost()
            ? $this->getRequest()->getPost()
            : $this->getRequest()->getQuery();
        if (isset($_FILES)) {
            $data = array_merge($data, $this->request->getUploadedFiles());
        }
        $this->setValues($data);

    }
159053
def update(self, _values=None, **values):
        
        if _values is not None:
            values.update(_values)

        return self._query.update(self._add_updated_at_column(values))
8856
def fetch(db=None, sql=None):
    '''
    
    '''
    cur = _connect(db)

    if not cur:
        return False

    cur.execute(sql)
    rows = cur.fetchall()
    return rows
651130
def init_db():
    
    with current_app.app_context():
        for filename in CHILL_CREATE_TABLE_FILES:
            db.execute(text(fetch_query_string(filename)))
102394
private function update()
    {
        $Eresus = Eresus_CMS::getLegacyKernel();

        $item = $Eresus->db->selectItem($this->table['name'], "`id`='" . arg('update') . "'");
        $old_file = $item['image'];
        $item['caption'] = arg('caption', 'dbsafe');
        $item['active'] = arg('active', 'int');
        if (arg('section'))
        {
            $item['section'] = '|' . implode('|', arg('section')) . '|';
        }
        $item['block'] = arg('block', 'dbsafe');
        $item['priority'] = arg('priority', 'int');
        $item['showFrom'] = arg('showFrom', 'dbsafe');
        $item['showTill'] = arg('showTill', 'dbsafe');
        $item['showCount'] = arg('showCount', 'int');
        $item['html'] = arg('html', 'dbsafe');
        $item['image'] = arg('image');
        $item['width'] = arg('width', 'int');
        $item['height'] = arg('height', 'int');
        $item['url'] = arg('url', 'dbsafe');
        $item['target'] = arg('target', 'dbsafe');

        if ($item['showTill'] == '')
        {
            unset($item['showTill']);
        }
        if (arg('flushShowCount'))
        {
            $item['shows'] = 0;
        }
        if (is_uploaded_file($_FILES['image']['tmp_name']))
        {
            $path = $Eresus->fdata . $this->name . '/';
            if (is_file($path . $old_file))
            {
                unlink($path . $old_file);
            }
            $filename = 'banner' . $item['id'] .
                substr($_FILES['image']['name'], strrpos($_FILES['image']['name'], '.'));
            upload('image', $path . $filename);
            $item['image'] = $filename;
        }

        $Eresus->db->updateItem($this->table['name'], $item, "`id`='" . $item['id'] . "'");

        if ($item['showTill'] == '')
        {
            $Eresus->db->query(
                "UPDATE " . $Eresus->db->prefix . $this->table['name'] .
                " SET `showTill` = NULL WHERE `id`='" . $item['id'] . "'");
        }

        HTTP::redirect(arg('submitURL'));
    }
1044381
def update(self, _values=None, **values):
        
        if _values is not None:
            values.update(_values)

        values = OrderedDict(sorted(values.items()))

        bindings = list(values.values()) + self.get_bindings()

        sql = self._grammar.compile_update(self, values)

        return self._connection.update(sql, self._clean_bindings(bindings))