# Website data

> Every website has its own database. See the data it collects, export it, read the logs, restore a backup, and store secrets safely.

Every website has its own database. Waitlist sign-ups, survey answers, pre-orders and accounts all land there, and the data view is where you see them. It also holds the site's logs, its backups, and the secrets it needs to talk to other services.

*The data view: the site's tables on the left, the rows on the right.*

## Opening the data view

Open the website in the reader and click the database icon on the toolbar switch. The globe icon takes you back to the site. The list on the left shows every table in the database, then **Logs**, **Backups** and **Secrets**. On a narrow screen the list becomes a dropdown at the top.

## One database for preview and live

The preview and the published site share the same database. A form you submit in the preview creates a real row, and a row the live site creates shows up when you test in the preview. Keep that in mind when you try things out, and delete your test rows afterwards, or ask Buildpad to.

## Tables

Click a table to see its rows, newest first, 50 per page. The top bar shows the row count. Empty cells show a dash. You cannot edit rows here, but you can ask Buildpad to add, change or delete data for you, and every change it makes is logged and can be undone from **Backups**.

Tables are created by the website's own code, so a new form or feature brings its table with it.

**Export CSV** downloads the whole table, oldest first, as a file that opens in any spreadsheet app. The file is named after the website and the table.

## Logs

*The log shows what the site's server did, newest first.*

**Logs** lists what happened on the server side of the site, with the time and a chip for the kind of entry:

- **ok**, **error** and **crash** are calls to the site's server functions, like a form being submitted, with how long they took and any error message. A **preview** chip marks calls made from the preview rather than the live site.
- Calls to the site's API routes, with the method, path and status code.
- **exception** is an error the server code did not handle.
- Console output from the server code, as **log**, **warn** or **error**.
- **fetch** is a request the server made to another service, with its status.
- **sql** is a data change Buildpad made for you, with the statement and how many rows changed.
- **restore** marks a restore of the database.

The newest 200 entries are shown and the last 1,000 are kept. Secret values never appear in the log: wherever one would, you see the secret's name instead.

## Backups

*Restore points: one a day, plus one before every change Buildpad makes to the data.*

**Backups** lists the points you can take the database back to:

- **Daily backup**, at midnight, for each of the last 30 days back to the day the website was created.
- A point right before every data change Buildpad made, labeled with the statement it ran.
- **Before the restore**, so you can undo a restore.

Click **Restore** on a point. The dialog tells you the moment the database goes back to, and warns you that everything saved after that moment is lost and that tables and columns go back too. Confirm with **Restore**. Then ask Buildpad to check the website, since code written after that point may expect a table or column that no longer exists.

## Secrets

*Adding a secret. The site reads it on the server, and only the name is shown again.*

When the site needs to talk to another service, like a payment provider or a mailing list tool, it needs that service's API key. Keys do not belong in the code or in the chat, so they go in **Secrets**. Buildpad names the key it needs and asks you to add it:

1. Open **Secrets** and click **Add secret**.
2. Enter the name Buildpad asked for. Names are capital letters, digits and underscores, and are uppercased as you type.
3. Paste the value and click **Save**.

The site reads the secret on the server when it runs, so visitors never see it, and it is kept out of the logs. Only names are listed afterwards. To change a value, save a secret with the same name again. **Remove** deletes one. A website can hold up to 50 secrets.

## Asking Buildpad about the data

You do not have to read the tables yourself. In the chat, ask things like:

- "How many people joined the waitlist this week?"
- "Which scent did people pick most in the survey?"
- "Delete the test rows with my own email."
- "Why did the form fail yesterday afternoon?"

Buildpad queries the database directly, reads the logs, and can send a test request to the site to see what happens. Changes it makes are logged and create a restore point.

## What happens to the data

The database lives as long as the website. Unpublishing and pausing keep it. Deleting the website deletes the database with it, so export your tables first if you want to keep them.

> **Tip:** Export a table before you ask for a big change to the form behind it. A CSV on your computer is the one backup that does not depend on anything else.
