---
title: "Toggle Databases State Operation  (Enable / Disable)"
url: "https://docs.ravendb.net/6.2/client-api/operations/server-wide/toggle-databases-state"
version: "6.2"
language: "python"
---

# Toggle Databases State Operation  (Enable / Disable)

> Client language: Python. Also available for [C#](https://docs.ravendb.net/6.2/client-api/operations/server-wide/toggle-databases-state.md), [PHP](https://docs.ravendb.net/6.2/client-api/operations/server-wide/toggle-databases-state.php.md), [Node.js](https://docs.ravendb.net/6.2/client-api/operations/server-wide/toggle-databases-state.nodejs.md).
>
> RavenDB publishes an official agent skill for coding assistants at https://docs.ravendb.net/skills/ravendb/SKILL.md (also installable with `npx skills add ravendb/skills`). The skill describes itself as: "Read this before writing any RavenDB query, client call or /databases/ request. Covers server setup, document modelling, the Node.js, .NET and Python clients, RQL, indexes, vector search and AI agents. Code written from recall tends to run and return the wrong rows, because RQL resembles SQL and the clients take field names as plain strings."

> **Note**
>
> - Use `ToggleDatabasesStateOperation` to enable/disable a single database or multiple databases.
>
> - The database will be enabled/disabled on all nodes in the [database-group](https://docs.ravendb.net/6.2/studio/database/settings/manage-database-group.md).
>
> - In this page:
>
>   - [Enable/Disable database from the Client API](#enable/disable-database-from-the-client-api)
>     - [Enable database](#enable-database)
>     - [Disable database](#disable-database)
>     - [Syntax](#syntax)
>   - [Disable database via the file system](#disable-database-via-the-file-system)

## Enable/Disable database from the Client API

#### Enable database:

```python
# Define the toggle state operation
# specify the database name & pass 'False' to enable
enable_database_op = ToggleDatabasesStateOperation("Northwind", disable=False)

# To enable multiple databases use:
# enable_database_op = ToggleDatabasesStateOperation.from_multiple_names(["DB1", "DB2", ...], disable=False)

# Execute the operation by passing it to maintenance.server.send
toggle_result = store.maintenance.server.send(enable_database_op)
```

#### Disable database:

```python
# Define the toggle state operation
# specify the database name(s) & pass 'True' to disable
disable_database_op = ToggleDatabasesStateOperation("Northwind", disable=True)

# To disable multiple databases use:
# enable_database_op = ToggleDatabasesStateOperation.from_multiple_names(["DB1", "DB2", ...], disable=True)

# Execute the operation by passing it to maintenance.server.send
toggle_result = store.maintenance.server.send(disable_database_op)
```

#### Syntax:

```python
class ToggleDatabasesStateOperation(ServerOperation[DisableDatabaseToggleResult]):
  def __init__(self, database_name: str, disable: bool): ...
  @classmethod
  def from_multiple_names(cls, database_names: List[str], disable: bool): ...
```

| Parameter | Type | Description |
| - | - | - |
| **database\_name** | `str` | Name of database for which to toggle state |
| **database\_names** | `str[]` | List of database names for which to toggle state |
| **disable** | `bool` | `True` - request to disable the database(s)<br />`False`- request to enable the database(s) |

```python
class DisableDatabaseToggleResult:
  def __init__(
      self, disabled: bool = None, name: str = None, success: bool = None, reason: str = None
  ) -> None:
      self.disabled = disabled  # Is database disabled
      self.name = name  # Name of the database
      self.success = success  # Has request succeeded
      self.reason = reason  # Reason for success or failure
```

## Disable database via the file system

It may sometimes be useful to disable a database manually, through the file system.

- To **manually disable** a database:

  - Place a file named `disable.marker` in the [database directory](https://docs.ravendb.net/6.2/server/storage/directory-structure.md).
  - The `disable.marker` file can be empty,  
    and can be created by any available method, e.g. using the File Explorer, a terminal, or code.

- Attempting to use a manually disabled database will generate the following exception:

  Unable to open database: '{DatabaseName}',
  it has been manually disabled via the file: '{disableMarkerPath}'.
  To re-enable, remove the disable.marker and reload the database.

- To **enable** a manually disabled database:

  - First, remove the `disable.marker` file from the database directory.
  - Then, [reload the database](https://docs.ravendb.net/6.2/studio/database/settings/database-settings.md#how-to-reload-the-database).

## See also

- [Database settings operations](https://docs.ravendb.net/6.2/client-api/operations/maintenance/configuration/database-settings-operation.md)
- [Database-group](https://docs.ravendb.net/6.2/studio/database/settings/manage-database-group.md)
