Destroy a database and disconnect
553684
function dropDatabase (db, fn) {
  db.connection.db.executeDbCommand({
    dropDatabase: 1
  }, function(err, result) {
    db.disconnect()
    fn && fn(err, result)
  })
}
253652
def delete_database(self, database):
        
        url = "db/{0}".format(database)

        self.request(
            url=url,
            method='DELETE',
            expected_response_code=204
        )

        return True
257996
def close_db(fn):
    """"""
    @wraps(fn)
    def inner(*args, **kwargs):
        try:
            return fn(*args, **kwargs)
        finally:
            if not HUEY.immediate:
                close_old_connections()
    return inner
1342126
def close_database_session(session):
    """"""

    try:
        session.close()
    except OperationalError as e:
        raise DatabaseError(error=e.orig.args[1], code=e.orig.args[0])
1129855
def unlock(self):
    """"""
    if not hasattr(self, 'session'):
      raise RuntimeError('Error detected! The session that you want to close does not exist any more!')
    logger.debug("Closed database session of '%s'" % self._database)
    self.session.close()
    del self.session
399401
public synchronized void stop() throws ManagedProcessException {
        if (mysqldProcess.isAlive()) {
            logger.debug("Stopping the database...");
            mysqldProcess.destroy();
            logger.info("Database stopped.");
        } else {
            logger.debug("Database was already stopped.");
        }
    }
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)
268936
def delete(self, instance):
        ''''''
        flushdb(self.client) if flushdb else self.client.flushdb()
543137
def cleanup(self):
        
        # Closes connections to all databases to avoid the long running process
        # from holding connections indefinitely.
        for alias in db.connections.databases:
            logger.info('Closing database connection: %s', alias)
            db.connections[alias].close()
378896
def db_remove(name, user=None, password=None, host=None, port=None, authdb=None):
    '''
    
    '''
    conn = _connect(user, password, host, port, authdb=authdb)
    if not conn:
        return 'Failed to connect to mongo database'

    try:
        log.info('Removing database %s', name)
        conn.drop_database(name)
    except pymongo.errors.PyMongoError as err:
        log.error('Removing database %s failed with error: %s', name, err)
        return six.text_type(err)

    return True
283455
public function destroy()
    {
        // delete DB
        $sql = sprintf(
            'DROP TABLE `%s`;',
            $this->mysql->quote($this->section)
        );

        if (false === $this->mysql->exec($sql)) {

            $this->throwException(
                'Unable to delete the database: ',
                $this->mysql->errorInfo()
            );
        }

        $this->registry[$this->section] = array();
    }
857565
def cmd_kill():
    """"""
    db = connect()
    count = terminate(db, args.databases)
    if count == 0:
        log.error("No connections could be killed")
        # Return status 1, like killall
        sys.exit(1)
75213
def drop_database(self, name, deleteData, cascade):
    
    self.send_drop_database(name, deleteData, cascade)
    self.recv_drop_database()
372802
def delete_database(mongo_uri, database_name):
    
    client = pymongo.MongoClient(mongo_uri)

    client.drop_database(database_name)
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)
  })
}
621761
def delete(sql, *args, **kwargs):
        """"""
        assert "delete" in sql.lower(), 'This function requires a delete statement, provided: {}'.format(sql)
        CoyoteDb.execute_and_commit(sql, *args, **kwargs)
1326514
def close(self):
        

        self.__decrement_connection_counter()
        if self.connection_count == 0:
            if self.dbfile == ":memory:":
                SQL = """DROP TABLE IF EXISTS __self__"""
                self.sql(SQL, asrecarray=False, cache=False)
            else:
                self.connection.commit()
                self.connection.close()