# Creating and querying database snapshots

To provide data for the mock API to query, you create database snapshots. Fabricate stores the snapshot data internally.

## Creating a snapshot <a href="#snapshot-create" id="snapshot-create"></a>

To create a database snapshot of the current rule-based database data:

1. If no snapshots are currently configured, click **Create a DB Snapshot**.
2. If there are existing snapshots, then:
   1. Click the snapshot dropdown.
   2. In the dropdown, click **Create New Snapshot**.

<figure><img src="https://4109733485-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FmoU4gTR9LxlzHeWmQCUZ%2Fuploads%2FKRwOSib1ueMJlJdHY01b%2FDatabase_API_SnapshotDropdown.png?alt=media&#x26;token=3998416f-760f-4e4d-96e6-e087c4c5d731" alt=""><figcaption><p>Dropdown list of database snapshots</p></figcaption></figure>

3. On the **Create DB Snapshot** panel, in the **Snapshot Name** field, provide a name for the snapshot.\
   \
   Fabricate provides a default value of `v<snapshot count>`. For example, `v1` or `v2`.
4. Click **Create Snapshot**.\
   \
   Fabricate generates the snapshot and adds it to the dropdown list.

## Querying a snapshot <a href="#snapshot-query" id="snapshot-query"></a>

To verify the snapshot data works as expected, you can run queries against the snapshot.

To query a snapshot:

1. Click the snapshot dropdown.
2. In the dropdown list, select the snapshot to query against.
3. Click **SQL**.
4. On the **SQL Editor** panel, enter the query, then either:
   1. Press Enter.
   2. Click **Run Query**.

## Downloading a snapshot <a href="#snapshot-download" id="snapshot-download"></a>

You can download a snapshot. The snapshot is downloaded to a file named **\<database name>.sqlite**.

To download a snapshot:

1. Click the snapshot dropdown.
2. In the dropdown list, click the download icon for the snapshot.

## Removing a snapshot <a href="#snapshot-remove" id="snapshot-remove"></a>

To remove a snapshot:

1. Click the snapshot dropdown.
2. In the dropdown list, click the delete icon for the snapshot.
