Delete a DynamoDB table.

    CLI Example:

    .. code-block:: bash

        salt myminion boto_dynamodb.delete table_name region=us-east-1
495738
def delete(table_name, region=None, key=None, keyid=None, profile=None):
    '''
    
    '''
    conn = _get_conn(region=region, key=key, keyid=keyid, profile=profile)

    table = Table(table_name, connection=conn)
    table.delete()

    # Table deletion can take several seconds to propagate.
    # We will retry MAX_ATTEMPTS times.
    MAX_ATTEMPTS = 30
    for i in range(MAX_ATTEMPTS):
        if not exists(table_name, region, key, keyid, profile):
            return True
        else:
            time.sleep(1)   # sleep for one second and try again
    return False
106563
def delete_disk(kwargs=None, call=None):
    '''
    
    '''
    if call != 'function':
        raise SaltCloudSystemExit(
            'The delete_disk function must be called with -f or --function.'
        )

    if not kwargs or 'disk_name' not in kwargs:
        log.error(
            'A disk_name must be specified when deleting a disk.'
        )
        return False

    conn = get_conn()

    disk = conn.ex_get_volume(kwargs.get('disk_name'))

    __utils__['cloud.fire_event'](
        'event',
        'delete disk',
        'salt/cloud/disk/deleting',
        args={
            'name': disk.name,
            'location': disk.extra['zone'].name,
            'size': disk.size,
        },
        sock_dir=__opts__['sock_dir'],
        transport=__opts__['transport']
    )

    try:
        result = conn.destroy_volume(disk)
    except ResourceInUseError as exc:
        log.error(
            'Disk %s is in use and must be detached before deleting.\n'
            'The following exception was thrown by libcloud:\n%s',
            disk.name, exc, exc_info_on_loglevel=logging.DEBUG
        )
        return False

    __utils__['cloud.fire_event'](
        'event',
        'deleted disk',
        'salt/cloud/disk/deleted',
        args={
            'name': disk.name,
            'location': disk.extra['zone'].name,
            'size': disk.size,
        },
        sock_dir=__opts__['sock_dir'],
        transport=__opts__['transport']
    )
    return result
646437
def wipe_table(self, table: str) -> int:
        """"""
        sql = "DELETE FROM " + self.delimit(table)
        return self.db_exec(sql)
105925
def delete_state(key, namespace=None, table_name=None, environment=None,
                 layer=None, stage=None, shard_id=None, consistent=True,
                 wait_exponential_multiplier=500,
                 wait_exponential_max=5000, stop_max_delay=10000):
    """"""
    if table_name is None:
        table_name = _state_table_name(environment=environment, layer=layer,
                                       stage=stage)

    if not table_name:
        msg = ("Can't produce state table name: unable to set state "
               "item '{}'".format(key))
        logger.error(msg)
        raise StateTableError(msg)
        return

    dynamodb = boto3.resource("dynamodb")
    table = dynamodb.Table(table_name)
    logger.info("Deleting {} in DynamoDB table {}".format(key, table_name))

    if namespace:
        key = "{}:{}".format(namespace, key)

    if shard_id:
        key = "{}:{}".format(shard_id, key)

    @retry(retry_on_exception=_is_critical_exception,
           wait_exponential_multiplier=500,
           wait_exponential_max=5000,
           stop_max_delay=10000)
    def delete_item():
        try:
            return table.delete_item(Key={"id": key})
        except Exception as err:
            if _is_dynamodb_critical_exception(err):
                raise CriticalError(err)
            else:
                raise

    resp = delete_item()

    logger.info("Response from DynamoDB: '{}'".format(resp))
    return resp
968674
def destroy_ec2(region, instance_id, access_key_id, secret_access_key):
    
    conn = connect_to_ec2(region, access_key_id, secret_access_key)

    data = get_ec2_info(instance_id=instance_id,
                        region=region,
                        access_key_id=access_key_id,
                        secret_access_key=secret_access_key,
                        username=None)

    instance = conn.terminate_instances(instance_ids=[data['id']])[0]
    log_yellow('destroying instance ...')
    while instance.state != "terminated":
        log_yellow("Instance state: %s" % instance.state)
        sleep(10)
        instance.update()
    volume_id = data['volume']
    if volume_id:
        destroy_ebs_volume(region, volume_id, access_key_id,
                           secret_access_key)
    os.unlink('data.json')
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)
1304177
def delete(self, table):
        
        self._table = table
        self._limit = None
        self._query = "DELETE FROM {0}".format(self._table)

        return self
162008
def table_delete(self, table_name):
    
    url = Api._ENDPOINT + (Api._TABLES_PATH % table_name)
    return datalab.utils.Http.request(url, method='DELETE', credentials=self._credentials,
                                      raw_response=True)
1037136
def delete_joined_table_sql(qualified_name, removing_qualified_name, primary_key):
    

    condition_template = 't.{}=d.{}'
    where_clause = ' AND '.join(condition_template.format(pkey, pkey)
                                for pkey in primary_key)
    delete_statement = (
        'DELETE FROM {table} t'
        ' USING {delete_table} d'
        ' WHERE {where_clause}').format(table=qualified_name,
                                        delete_table=removing_qualified_name,
                                        where_clause=where_clause)
    return delete_statement
317993
protected function deleteTables()
    {
        if (empty( self::$tables )) {
            throw new \Exception('Cannot delete tables, as no configuration file given, or the ::$tables is not overridden.');
        }
        $client = $this->dynamoDb->getClient();

        $defaultAnswer = $this->input->getOption('yes');
        $a = 'n';
        foreach (self::$tables as $tableData) {
            $tableName = $tableData['TableName'];

            if ($this->tableExists($tableName)) {

                if ($defaultAnswer === false) {
                    $a = $this->ask(sprintf('Are you sure you want to delete table "%s"? [y/N]', $tableName), 'n');
                }

                if ($defaultAnswer || strtolower($a) === 'y') {
                    // Reset the answer.
                    $a = null;
                    $this->comment(sprintf('Deleting table "%s"', $tableName));

                    $client->deleteTable([
                        'TableName' => $tableName,
                    ]);
                    $client->waitUntil('TableNotExists', ['TableName' => $tableName]);

                    $this->info('Table deleted.');
                } else {
                    $this->comment(sprintf('Skipping table %s', $tableName));
                }
            } else {
                $this->warn(sprintf('Table "%s" does not exist.', $tableName));
            }
        }
    }
1202070
void deleteRow(String storeName, Map<String, AttributeValue> key) {
        String tableName = storeToTableName(storeName);
        m_logger.debug("Deleting row from table {}, key={}", tableName, DynamoDBService.getDDBKey(key));
        
        Timer timer = new Timer();
        boolean bSuccess = false;
        for (int attempts = 1; !bSuccess; attempts++) {
            try {
                m_ddbClient.deleteItem(tableName, key);
                if (attempts > 1) {
                    m_logger.info("deleteRow() succeeded on attempt #{}", attempts);
                }
                bSuccess = true;
                m_logger.debug("Time to delete table {}, key={}: {}",
                               new Object[]{tableName, DynamoDBService.getDDBKey(key), timer.toString()});
            } catch (ProvisionedThroughputExceededException e) {
                if (attempts >= m_max_commit_attempts) {
                    String errMsg = "All retries exceeded; abandoning deleteRow() for table: " + tableName;
                    m_logger.error(errMsg, e);
                    throw new RuntimeException(errMsg, e);
                }
                m_logger.warn("deleteRow() attempt #{} failed: {}", attempts, e);
                try {
                    Thread.sleep(attempts * m_retry_wait_millis);
                } catch (InterruptedException ex2) {
                    // ignore
                }
            }
        }
    }
669255
def delete(self, table_name, constraints=None):
    
    if constraints is None:
      constraints = "1=1"
    where, params = self.sql_writer.parse_constraints(constraints)
    sql = "delete from {0} where {1};".format(table_name, where)
    self.execute(sql, params)
645821
def delete_key_pair(region, pair_name)
      kp = client(region).describe_key_pairs(:key_names => [pair_name]).key_pairs.first
      unless kp.nil?
        @logger.debug("aws-sdk: delete key pair in region: #{region}")
        client(region).delete_key_pair(:key_name => pair_name)
      end
    rescue Aws::EC2::Errors::InvalidKeyPairNotFound
      nil
    end
570130
def delete(name, region=None, key=None, keyid=None, profile=None):
    '''
    
    '''
    conn = _get_conn(region=region, key=key, keyid=keyid, profile=profile)

    try:
        return conn.delete_stack(name)
    except BotoServerError as e:
        msg = 'Failed to create stack {0}.'.format(name)
        log.error(msg)
        log.debug(e)
        return six.text_type(e)
240165
def delete_table(cls):
        
        schema_editor = getattr(connection, 'schema_editor', None)
        if schema_editor:
            with connection.schema_editor() as schema_editor:
                schema_editor.delete_model(cls)
        else:
            cursor = connection.cursor()
            try:
                with warnings.catch_warnings():
                    warnings.filterwarnings('ignore', 'unknown table')
                    cursor.execute('DROP TABLE IF EXISTS {0}'.format(cls._meta.db_table))
            finally:
                cursor.close()
846393
def make_delete_table(table: Table, delete_prefix='delete_from__') -> Table:
    """"""

    name = delete_prefix + table.name
    primary_key = table.primary_key
    key_names = set(primary_key.column_names)
    columns = [column for column in table.columns if column.name in key_names]
    table = Table(name, columns, primary_key)

    return table
1061817
def delete(name, region=None, key=None, keyid=None, profile=None):
    '''
    
    '''
    conn = _get_conn(region=region, key=key, keyid=keyid, profile=profile)

    try:
        url = conn.get_queue_url(QueueName=name)['QueueUrl']
        conn.delete_queue(QueueUrl=url)
    except botocore.exceptions.ClientError as e:
        return {'error': __utils__['boto3.get_error'](e)}
    return {'result': True}