Drop and create DATABASES['default']
768410
def cleardb(force=False):
    """"""

    # Drop database, if it exists
    if db_exists():
        try:
            dropdb(force)
        except subprocess.CalledProcessError as error:
            output = error.output.decode("utf-8")
            if "is being accessed by other users" in output:
                raise ValueError(
                    "{}\n"
                    "To forcibly terminate other sessions, run "
                    "this command again with --force".format(output)
                )
            else:
                raise
    else:
        logger.info(
            "Database %s does not currently exist; no need to drop", repr(DB["NAME"])
        )
    createdb()
691368
def db_remove(database_name, **kwargs):
    '''
    
    '''
    try:
        if db_exists(database_name, **kwargs) and database_name not in ['master', 'model', 'msdb', 'tempdb']:
            conn = _get_connection(**kwargs)
            conn.autocommit(True)
            cur = conn.cursor()
            cur.execute('ALTER DATABASE {0} SET SINGLE_USER WITH ROLLBACK IMMEDIATE'.format(database_name))
            cur.execute('DROP DATABASE {0}'.format(database_name))
            conn.autocommit(False)
            conn.close()
            return True
        else:
            return False
    except Exception as e:
        return 'Could not find the database: {0}'.format(e)
102222
public function dispose() {
        // We shouldn't have any temp table registered at the end of the script.
        // So we error_log that and, at the same time, drop all the pending temptables
        if ($temptables = $this->get_temptables()) {
            error_log('Potential coding error - existing temptables found when disposing database. Must be dropped!');
            foreach ($temptables as $temptable) {
                 $this->mdb->get_manager()->drop_table(new xmldb_table($temptable));
            }
        }
        $this->mdb = null;
    }
891132
def create(args):
  """"""

  from bob.db.utils import session_try_nolock

  dbfile = args.files[0]

  if args.recreate:
    if args.verbose and os.path.exists(dbfile):
      print('unlinking %s...' % dbfile)
    if os.path.exists(dbfile): os.unlink(dbfile)

  if not os.path.exists(os.path.dirname(dbfile)):
    os.makedirs(os.path.dirname(dbfile))

  # the real work...
  create_tables(args)
  s = session_try_nolock(args.type, dbfile, echo=(args.verbose > 2))
  add_clients(s, args.verbose)
  add_files(s, args.imagedir, args.verbose)
  add_protocols(s, args.verbose)
  s.commit()
  s.close()
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)
  })
}
876816
def tear_down(self):
        
        # drop/delete the tables
        logger.info('resetting database...')
        BASE.metadata.drop_all(self.engine)
        return self
106570
def clear(**kwargs):
    

    database = kwargs.pop('database', False)
    expression = lambda target, table: table.drop(target)
    test = lambda x, tab: not database_exists(x.url) or not tab.exists(x)

    # TODO: Iterate through all engines in name set.
    if database and database_exists(engine['default'].url):
        drop_database(engine['default'].url)
        clear_cache()

    op(expression, reversed(metadata.sorted_tables), test=test,
       primary='clear', secondary='drop', **kwargs)
951252
private void createTables() {
        this.db.execSQL(DbConstants.DROP_METADATA_STATEMENT);
        this.db.execSQL(DbConstants.DROP_INDEX_STATEMENT);
        this.db.execSQL(DbConstants.DROP_CATEGORY_MAP_STATEMENT);
        this.db.execSQL(DbConstants.DROP_DATA_STATEMENT);
        this.db.execSQL(DbConstants.DROP_CATEGORIES_STATEMENT);

        this.db.execSQL(DbConstants.CREATE_CATEGORIES_STATEMENT);
        this.db.execSQL(DbConstants.CREATE_DATA_STATEMENT);
        this.db.execSQL(DbConstants.CREATE_CATEGORY_MAP_STATEMENT);
        this.db.execSQL(DbConstants.CREATE_INDEX_STATEMENT);
        this.db.execSQL(DbConstants.CREATE_METADATA_STATEMENT);
    }
1000928
public function dropSelectedDatabase()
    {
        $databaseName = $this->connector->getSelectedDatabase();
        if ($databaseName) {
            $this->connector->unloadDatabase();
            $this->schemaManager->dropDatabase($databaseName);
        }
    }
642077
def init_db():
    """"""
    with closing(connect_db()) as db:
        db.cursor().execute("DROP TABLE IF EXISTS entries")
        db.cursor().execute(
            """
            CREATE TABLE entries (
                id INTEGER PRIMARY KEY AUTOINCREMENT,
                title TEXT NOT NULL,
                text TEXT NOT NULL
            )
            """
        )
        db.commit()
362522
def reset(self):
        
        query = """
            DROP TABLE identifier_index;
        """
        self.backend.library.database.connection.execute(query)
816359
public static function drop_site() {

        if (!defined('BEHAT_UTIL')) {
            throw new coding_exception('This method can be only used by Behat CLI tool');
        }

        self::reset_dataroot();
        self::drop_database(true);
        self::drop_dataroot();
    }
490536
@Override
    public void dropSchema()
    {
        try
        {
            if (operation != null && ("create-drop").equalsIgnoreCase(operation))
            {
                r.dbDrop(databaseName);
            }
        }
        catch (Exception e)
        {
            logger.error("Error while dropping schema", e);
            throw new SchemaGenerationException(e, "RethinkDB");
        }
    }
516219
def clear():
    
    utils.check_for_local_server()
    click.confirm(
        "Are you sure you want to do this? It will delete all of your data",
        abort=True
    )
    server = Server(config["local_server"]["url"])
    for db_name in all_dbs:
        del server[db_name]
330974
function dropEnvironmentDatabase(domain, env, next) {
  _getEnvironmentDatabase({
    domain: domain,
    environment: env
  }, function (err, found) {
    if (err) {
      return next(common.buildErrorObject({
        err: err,
        msg: 'Failed to get environment',
        httpCode: 500
      }));
    }
    if (!found) {
      log.logger.info("no environment db for " + env + " moving on");
      return next();
    }
    found.dropDb(config.getConfig(), function dropped(err) {
      if (err) {
        log.logger.error('Failed to delete model');
        return next(common.buildErrorObject({
          err: err,
          msg: 'Failed to drop environment db',
          httpCode: 500
        }));
      }
      found.remove(next);
    });
  });
}
121365
function destroy() {
  this.conn = null;
  this.cmd = null;
  this.args = null;
  this.db = null;
  this.info = null;
  this.conf = null;
  this.def = null;
}
1057716
def db_create():
    """"""
    try:
        migrate_api.version_control(url=db_url, repository=db_repo)
        db_upgrade()
    except DatabaseAlreadyControlledError:
        print 'ERROR: Database is already version controlled.'