Deleting the rows from this DB which have state = 1
325779
public static function sync(bbn\db $db, $dbs='', $dbs_table='', $num_try = 0){

    if ( !$num_try ){
      self::def($dbs, $dbs_table);
      self::first_call();
      self::disable();
      $mode_db = self::$db->get_error_mode();
      $mode_dbs = self::$dbs->get_error_mode();
      self::$db->set_error_mode("continue");
      self::$dbs->set_error_mode("continue");
    }

    $num_try++;

    $to_log = [
      'deleted_sync' => 0,
      'deleted_real' => 0,
      'updated_sync' => 0,
      'updated_real' => 0,
      'inserted_sync' => 0,
      'inserted_real' => 0,
      'num_problems' => 0,
      'problems' => []
    ];


    $retry = false;

    $start = ( $test = self::$dbs->get_one("
      SELECT MIN(chrono)
      FROM ".self::$dbs->escape(self::$dbs_table)."
      WHERE db NOT LIKE ?
      AND state = 0",
      self::$db->current) ) ? $test : time();
    // Deleting the entries prior to this sync we produced and have been seen by the twin process
    $to_log['deleted_sync'] = self::$dbs->delete(self::$dbs_table, [
      ['db', '=', self::$db->current],
      ['state', '=', 1],
      ['chrono', '<', $start]
    ]);

    // Selecting the entries inserted
    $ds = self::$dbs->rselect_all(self::$dbs_table, ['id', 'tab', 'vals', 'chrono'], [
      ['db', '!=', self::$db->current],
      ['state', '=', 0],
      ['action', '=', 'insert']
    ], [
      'chrono' => 'ASC',
      'id' => 'ASC'
    ]);
    // They just have to be inserted
    foreach ( $ds as $i => $d ){
      if ( isset(self::$methods['cbf1']) ){
        self::cbf1($d);
      }
      $vals = \bbn\x::json_base64_decode($d['vals']);
      if ( !\is_array($vals) ){
        $to_log['num_problems']++;
        $to_log['problems'][] = "Hey, look urgently at the row $d[id]!";
      }
      else if ( self::$db->insert($d['tab'], $vals) ){
        if ( isset(self::$methods['cbf2']) ){
          self::cbf2($d);
        }
        $to_log['inserted_sync']++;
        self::$dbs->update(self::$dbs_table, ["state" => 1], ["id" => $d['id']]);
      }
      else if ( self::$db->select($d['tab'], [], $vals) ){
        self::$dbs->update(self::$dbs_table, ["state" => 1], ["id" => $d['id']]);
      }
      else{
        if ( $num_try > self::$max_retry ){
          $to_log['num_problems']++;
          $to_log['problems'][] = "Problem while syncing (insert), check data with status 5 and ID ".$d['id'];
          self::$dbs->update(self::$dbs_table, ["state" => 5], ["id" => $d['id']]);
        }
        $retry = 1;
      }
    }


    // Selecting the entries modified and deleted in the twin DB,
    // ordered by table and rows (so the same go together)
    $ds = self::$dbs->rselect_all(self::$dbs_table, ['id', 'tab', 'action', 'rows', 'vals', 'chrono'], [
      ['db', '!=', self::$db->current],
      ['state', '=', 0],
      ['rows', '!=', '[]'],
      ['action', '!=', 'insert']
    ], [
      'tab' => 'ASC',
      'rows' => 'ASC',
      'chrono' => 'ASC',
      'id' => 'ASC'
    ]);
    foreach ( $ds as $i => $d ){
      // Executing the first callback
      $d['rows'] = bbn\x::json_base64_decode($d['rows']);
      $d['vals'] = bbn\x::json_base64_decode($d['vals']);
      if ( isset(self::$methods['cbf1']) ){
        self::cbf1($d);
      }
      // Proceeding to the actions: delete is before
      if ( strtolower($d['action']) === 'delete' ){
        if ( self::$db->delete($d['tab'], $d['rows']) ){
          self::$dbs->update(self::$dbs_table, ["state" => 1], ["id" => $d['id']]);
          $to_log['deleted_real']++;
        }
        else if ( !self::$db->select($d['tab'], [], $d['rows']) ){
          self::$dbs->update(self::$dbs_table, ["state" => 1], ["id" => $d['id']]);
        }
        else{
          if ( $num_try > self::$max_retry ){
            self::$dbs->update(self::$dbs_table, ["state" => 5], ["id" => $d['id']]);
            $to_log['num_problems']++;
            $to_log['problems'][] = "Problem while syncing (delete), check data with status 5 and ID ".$d['id'];
          }
          $retry = 1;
        }
      }
      // Checking if there is another change done to this record and when in the twin DB
      $next_time = (
              isset($ds[$i+1]) &&
              ($ds[$i+1]['tab'] === $d['tab']) &&
              ($ds[$i+1]['rows'] === $d['rows'])
            ) ? $ds[$i+1]['chrono'] : microtime();
      // Looking for the actions done on this specific record in our database
      // between the twin change and the next (or now if there is no other change)
      $each = self::$dbs->rselect_all(self::$dbs_table, ['id', 'chrono', 'action', 'vals'], [
        ['db', '=', self::$db->current],
        ['tab', '=', $d['tab']],
        ['rows', '=', $d['rows']],
        ['chrono', '>=', $d['chrono']],
        ['chrono', '<', $next_time],
      ]);
      if ( \count($each) > 0 ){
        $to_log['num_problems']++;
        $to_log['problems'][] = "Conflict!";
        $to_log['problems'][] = $d;
        foreach ( $each as $e ){
          // If it's deleted locally and updated on the twin we restore
          if ( strtolower($e['action']) === 'delete' ){
            if ( strtolower($d['action']) === 'update' ){
              if ( !self::$db->insert_update(
                      $d['tab'],
                      bbn\x::merge_arrays(
                        $e['vals'],
                        $d['vals']
                      ))
              ){
                $to_log['num_problems']++;
                $to_log['problems'][] = "insert_update number 1 had a problem";
              }
            }
          }
          // If it's updated locally and deleted in the twin we restore
          else if ( strtolower($e['action']) === 'update' ){
            if ( strtolower($d['action']) === 'delete' ){
              if ( !self::$db->insert_update($d['tab'], bbn\x::merge_arrays($d['vals'], $e['vals'])) ){
                $to_log['num_problems']++;
                $to_log['problems'][] = "insert_update had a problem";
              }
            }
          // If it's updated locally and in the twin we merge the values for the update
            else if ( strtolower($d['action']) === 'update' ){
              $d['vals'] = bbn\x::merge_arrays($d['vals'], $e['vals']);
            }
          }
        }
      }
      // Proceeding to the actions update is after in case we needed to restore
      if ( strtolower($d['action']) === 'update' ){
        if ( self::$db->update($d['tab'], $d['vals'], $d['rows']) ){
          self::$dbs->update(self::$dbs_table, ["state" => 1], ["id" => $d['id']]);
          $to_log['updated_real']++;
        }
        else if ( self::$db->select($d['tab'], [], bbn\x::merge_arrays($d['rows'], $d['vals'])) ){
          self::$dbs->update(self::$dbs_table, ["state" => 1], ["id" => $d['id']]);
        }
        else{
          if ( $num_try > self::$max_retry ){
            self::$dbs->update(self::$dbs_table, ["state" => 5], ["id" => $d['id']]);
            $to_log['num_problems']++;
            $to_log['problems'][] = "Problem while syncing (update), check data with status 5 and ID ".$d['id'];
          }
          $retry = 1;
        }
      }
      // Callback number 2
      if ( isset(self::$methods['cbf2']) ){
        self::cbf2($d);
      }
    }


    $res = [];
    foreach ( $to_log as $k => $v ){
      if ( !empty($v) ){
        $res[$k] = $v;
      }
    }
    if ( $retry && ( $num_try <= self::$max_retry ) ){
      $res = bbn\x::merge_arrays($res, self::sync($db, $dbs, $dbs_table, $num_try));
    }
    else{
      self::$db->set_error_mode($mode_db);
      self::$dbs->set_error_mode($mode_dbs);
      self::enable();
    }
    return $res;
  }
964507
def action_delete(self, ids):
        """"""
        is_current = any(SessionActivity.is_current(sid_s=id_) for id_ in ids)
        if is_current:
            flash('You could not remove your current session', 'error')
            return
        for id_ in ids:
            delete_session(sid_s=id_)
        db.session.commit()
724586
public int delete(TRow row) {
		int numDeleted;
		if (row.hasId()) {
			numDeleted = deleteById(row.getId());
		} else {
			numDeleted = delete(buildValueWhere(row.getAsMap()),
					buildWhereArgs(row.getValues()));
		}
		return numDeleted;
	}
410962
function clearLocalDatabase() {
    idb.open('web-push-db', 1).then(db => {
        let tx = db.transaction(['web-push-subcription'], 'readwrite');
        tx.objectStore('web-push-subcription').clear();
        return tx.complete;
    });
}
1269406
def apply_to(self,
                 db: Union[BaseDB, ABC_Mutable_Mapping],
                 apply_deletes: bool = True) -> None:
        
        for key, value in self._changes.items():
            if value is DELETED:
                if apply_deletes:
                    try:
                        del db[key]
                    except KeyError:
                        pass
                else:
                    pass
            else:
                db[key] = value
137346
public function delete()
    {
        $data = $this->getData();
        if (isset($this->currentId))
            unset($data[$this->currentKey]);
        elseif($this->documentEntries)
            $data = array_diff_key($data,$this->documentEntries);
        else
            $data = [];
        $this->documentEntries = array_values($data);
        return $this->databaseDocument->put($this->documentEntries) ? true : false;
    }
788381
def execute(query, data=None):
    
    connection = _State.connection()
    _State.new_transaction()

    if data is None:
        data = []

    result = connection.execute(query, data)

    _State.table = None
    _State.metadata = None
    try:
        del _State.table_pending
    except AttributeError:
        pass

    if not result.returns_rows:
        return {u'data': [], u'keys': []}

    return {u'data': result.fetchall(), u'keys': list(result.keys())}
445526
def delete(table, where=(), **kwargs):
    """"""
    where = dict(where, **kwargs).items()
    sql, args = makeSQL("DELETE", table, where=where)
    return execute(sql, args).rowcount
459544
public function delete()
	{
		$this->frozen(true);
		$query = \DB::delete(static::$_table_name)
		            ->where(static::primary_key(), '=', $this->{static::primary_key()});

		$this->pre_delete($query);
		$result = $query->execute(static::get_connection(true));

		return $this->post_delete($result);
	}
252597
def delete_records(keep=20):
    """"""
    sql = "SELECT * from records where is_deleted<>1 ORDER BY id desc LIMIT -1 offset {}".format(keep)
    assert isinstance(g.db, sqlite3.Connection)
    c = g.db.cursor()
    c.execute(sql)
    rows = c.fetchall()
    for row in rows:
        name = row[1]
        xmind = join(app.config['UPLOAD_FOLDER'], name)
        xml = join(app.config['UPLOAD_FOLDER'], name[:-5] + 'xml')

        for f in [xmind, xml]:
            if exists(f):
                os.remove(f)

        sql = 'UPDATE records SET is_deleted=1 WHERE id = ?'
        c.execute(sql, (row[0],))
        g.db.commit()
1026512
def delete(self, row):
        """"""
        i = self._get_key_index(row)
        del self.keys[i]
426115
public function delete()
    {
        $sql = 'DELETE FROM '.$this->getTableName().' ';

        $pk_name = $this->getPkName();
        $params = [];

        if (is_array($pk_name)) {
            $pk_condition = [];
            foreach ($pk_name as $pk) {
                $pk_condition[] = "{$pk} = :_{$pk}";
                $params[":_{$pk}"] = $this->{$pk};
            }
            $pk_condition = implode(' AND ', $pk_condition);
        } else {
            $pk_condition = "`{$pk_name}` = :_{$pk_name}";
            $params[":_{$pk_name}"] = $this->{$pk_name};
        }

        $sql .= " WHERE {$pk_condition}";

        $stmt = $this->getDB()->prepare($sql);
        $stmt->execute($params);

        $stmt->closeCursor();

        return true;
    }
266715
@Override
    public void clear() {
        RocksIterator iterator = db.newIterator();
        while (iterator.isValid())
            try {
                db.remove(iterator.key());
            } catch (RocksDBException e) {
                throw new RuntimeException(e);
            }
        iterator.close();
        size = 0;
    }
1087377
def delete(self):
        
        resp = self.r_session.delete(self.database_url)
        resp.raise_for_status()
60870
def prune_database():
    
    now = datetime.now()
    expired = TokenBlacklist.query.filter(TokenBlacklist.expires < now).all()
    for token in expired:
        db.session.delete(token)
    db.session.commit()
189734
def delete(self):
        
        cmd = "delete from {table} {where_clause}".format(
            table=self.table_name,
            where_clause=self.where_clause
        ).rstrip()
        Repo.db.execute(cmd, self.where_values)
147607
def delete(sql_params = "", *bindvars)
      delete_sql = "DELETE FROM \"#{@schema_name}\".\"#{@table_name}\" "
      case sql_params
      when String
        delete_sql << sql_params
      when Hash
        raise ArgumentError, "Cannot specify bind variables when passing WHERE conditions as Hash" unless bindvars.empty?
        where_sqls = []
        sql_params.each do |k, v|
          where_sqls << "#{k} = :#{k}"
          bindvars << v
        end
        delete_sql << "WHERE " << where_sqls.join(" AND ") unless where_sqls.empty?
      else
        raise ArgumentError, "Only String or Hash can be provided as SQL condition argument"
      end
      @schema.execute(delete_sql, *bindvars)
    end