Removes a databases from the MySQL server.

    CLI Example:

    .. code-block:: bash

        salt '*' mysql.db_remove 'dbname'
964824
def db_remove(name, **connection_args):
    '''
    
    '''
    # check if db exists
    if not db_exists(name, **connection_args):
        log.info('DB \'%s\' does not exist', name)
        return False

    if name in ('mysql', 'information_scheme'):
        log.info('DB \'%s\' may not be removed', name)
        return False

    # db does exists, proceed
    dbc = _connect(**connection_args)
    if dbc is None:
        return False
    cur = dbc.cursor()
    s_name = quote_identifier(name)
    # identifiers cannot be used as values
    qry = 'DROP DATABASE {0};'.format(s_name)
    try:
        _execute(cur, qry)
    except MySQLdb.OperationalError as exc:
        err = 'MySQL Error {0}: {1}'.format(*exc.args)
        __context__['mysql.error'] = err
        log.error(err)
        return False

    if not db_exists(name, **connection_args):
        log.info('Database \'%s\' has been removed', name)
        return True

    log.info('Database \'%s\' has not been removed', name)
    return False
796341
public function clearDatabase()
    {
        try {
            $dsn = 'mysql:host=' . $this->host . ';dbname=' . $this->database;
            $options = [\PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES UTF8'];
            $connect = new \PDO($dsn, $this->user, $this->pass, $options);
            $connect->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION);

            $command = $connect->prepare("show tables");
            $command->setFetchMode(\PDO::FETCH_ASSOC);
            $command->execute();
            $results = $command->fetchAll();

            if(!empty($results)) {
                foreach ($results as $result) {
                    foreach ($result as $dba => $table){
                        $command = $connect->prepare("DROP TABLE IF EXISTS {$table}");
                        $command->execute();
                    }
                }
            }

        } catch (\PDOException $e) {
            return false;
        }
    }
976946
def drop_all(self):
        '''  '''
        self.drop(self.get_table_names())
        if self.persistent:
            with self._lock:
                try:
                    dbfolder = os.path.join(self.root_dir, self.name)
                    if os.path.exists(dbfolder) and not os.listdir(dbfolder):
                        rmtree(dbfolder)
                except (IOError, WindowsError):
                    self._print('Failed to delete folder %s when dropping database' % self.name)
                finally:
                    del self
235401
def delete(self, db_session=None):
        
        db_session = get_db_session(db_session, self)
        db_session.delete(self)
1003072
def destroy():
    """"""
    if not os.path.exists(ARGS.database):
        exit('Error: The database does not exist; you must create it first.')
    if ARGS.force:
        os.remove(ARGS.database)
    elif raw_input('Destroy {0} [y/n]? '.format(ARGS.database)) in ('y', 'Y'):
        os.remove(ARGS.database)
269484
def DbRenameServer(self, argin):
        
        self._log.debug("In DbRenameServer()")

        if len(argin) < 2:
            self.warn_stream("DataBase::DbRenameServer(): insufficient number of arguments ")
            th_exc(DB_IncorrectArguments,
                   "insufficient number of arguments (two required: old name and new name",
                   "DataBase::DbRenameServer")

        old_name = argin[0]
        new_name = argin[1]

        if ('/' not in argin[0]) or ('/' not in argin[1]):
            self.warn_stream("DataBase::DbRenameServer(): wrong syntax in command args ")
            th_exc(DB_IncorrectArguments,
                   "Wrong syntax in command args (ds_exec_name/inst_name)",
                   "DataBase::DbRenameServer")

        self.db.rename_server(old_name, new_name)
816389
def remove():
    
    if exists(env.venv_path):
        run("rm -rf %s" % env.venv_path)
    if exists(env.proj_path):
        run("rm -rf %s" % env.proj_path)
    for template in get_templates().values():
        remote_path = template["remote_path"]
        if exists(remote_path):
            sudo("rm %s" % remote_path)
    if exists(env.repo_path):
        run("rm -rf %s" % env.repo_path)
    sudo("supervisorctl update")
    psql("DROP DATABASE IF EXISTS %s;" % env.proj_name)
    psql("DROP USER IF EXISTS %s;" % env.proj_name)
507387
async def remove(self, *instances, using_db=None) -> None:
        
        db = using_db if using_db else self.model._meta.db
        if not instances:
            raise OperationalError("remove() called on no instances")
        through_table = Table(self.field.through)

        if len(instances) == 1:
            condition = (getattr(through_table, self.field.forward_key) == instances[0].id) & (
                getattr(through_table, self.field.backward_key) == self.instance.id
            )
        else:
            condition = (getattr(through_table, self.field.backward_key) == self.instance.id) & (
                getattr(through_table, self.field.forward_key).isin([i.id for i in instances])
            )
        query = db.query_class.from_(through_table).where(condition).delete()
        await db.execute_query(str(query))
542462
function destroyDatabase(name, cb) {
  if(name === user_dbname)
    throw new Error('We never ever delete that database.')
  nano().db.destroy(name, function(err) {
    if(err && err.status_code !== 404) return cb(err)
    cb(null, err ? false : true)
  })
}
1372878
def drop_database(self, name, force=False):
        
        tables = []

        if not force or self.database(name):
            tables = self.list_tables(database=name)

        if not force and len(tables):
            raise com.IntegrityError(
                'Database {0} must be empty before being dropped, or set '
                'force=True'.format(name)
            )
        statement = ddl.DropDatabase(name)
        self._execute(statement)
372802
def delete_database(mongo_uri, database_name):
    
    client = pymongo.MongoClient(mongo_uri)

    client.drop_database(database_name)
737442
def DbDeleteServer(self, argin):
        
        self._log.debug("In DbDeleteServer()")

        if '*' in argin or '%' in argin or not '/' in argin:
            self.warn_stream("DataBase::db_delete_server(): server name " + argin + " incorrect ")
            th_exc(DB_IncorrectServerName,
                   "failed to delete server, server name incorrect",
                   "DataBase::DeleteServer()")

        self.db.delete_server(argin)
417609
def drop_database(self):
        
        self.print_message("Dropping database '%s'" % self.databases['destination']['name'])
        self.export_pgpassword('destination')
        args = [
            "dropdb",
            "--if-exists",
            self.databases['destination']['name'],
        ]
        args.extend(self.databases['destination']['args'])
        subprocess.check_call(args)
874699
def delete(self, instance):
        
        
        #TODO: Really drop the database based on a policy set in `instance.parameters`.
        #
        #      We need :
        #      - Set a policy in parameters of the instance (eg: policy-on-delete : retain|drop    => default to retain)
        #      - to check that the database name `instance.get_dbname()` is not in use by another instance (shared database)
        #      - credential on the Atlas cluster `instance.get_cluster()` to drop the database
        #
        
        self.backend.storage.remove(instance)
        
        return DeprovisionServiceSpec(False, "done")
20727
def drop(self, force=False):
        
        self.client.drop_database(self.name, force=force)
465753
protected function removeConnection($db_sock) {
        swoole_event_del($db_sock);
        $this->idle_pool[$db_sock]['object']->close();
        unset($this->idle_pool[$db_sock]);
        $this->connection_num--;
    }
84826
def remove(self):
        
        ''' 
                
        '''
        
        self.table.drop(self.engine)
        
        exit_msg = '%s table has been removed from %s database.' % (self.table_name, self.database_name)
        self.printer(exit_msg)
        
        return exit_msg