AirBuild services

Browse your app's tables, run your own SQL and read the results in the Databases tab, and add or delete a database.

Your app keeps its data in databases on AirHost. A database belongs to the app, not to one service: it stays when the service that uses it is removed. The Databases tab in the Project lets you see what’s in them. To open the tab, see Host your app’s backend, database and sign-in (AirHost).

Anyone in the Team can browse, query, add and delete databases, not only the Team’s owner.

If your app has no database yet, the tab says Store This App’s Data and offers Ask Agents to Add. See Host your app’s backend, database and sign-in (AirHost).

The list of databases

At the top, Databases counts them and In Use counts the ones a service uses. Each row shows the database’s name and either “Used by” with the service’s name, or “Not connected to a service”. A database a service uses says In Use at the end of its row.

Tap a database to open it. Touch and hold a row (on the Mac, right-click it) for Open Database and Delete Database.

On iPhone the database opens as the next page. On the Mac and iPad it opens as a sheet. Its title is the database’s name.

Browse a table

  1. Open the database. Under Tables, each table is a button. A database with none says “No tables yet.”
  2. Tap a table. The app writes a query for the table’s first 50 rows into SQL and runs it.
  3. The rows appear under Results.

The query it writes looks like this, with the table’s name:

SELECT * FROM "table_name" LIMIT 50;

To see other rows, change that query and run it again (see the next section). For example, to see the newest 50 rows of a table that has an id column:

SELECT * FROM "table_name" ORDER BY id DESC LIMIT 50;

Tables leaves out the tables the database keeps for its own use. A query in SQL can still read them.

Run your own query

Queries are written in SQLite’s SQL. The query SQL starts with is SQLite’s way to list the tables:

SELECT name FROM sqlite_master WHERE type = 'table' ORDER BY name;
  1. Open the database. SQL already holds the query above.
  2. Replace it with your own SQL.
  3. Tap Run. It’s at the top of the page on iPhone and iPad, and at the bottom of the sheet on the Mac.

Run stays off while SQL is empty, and turns into a spinner while the query runs.

Read the results

What you see What it means
The header Results, then a number of rows and of milliseconds How many rows came back and how long the query took.
One column per field The id column comes first if there is one; the others follow in alphabetical order, not in the table’s order.
NULL The field is empty.
A cell cut off at the end Each cell shows one line, so a long value is cut off. You can select a cell’s text to copy it.
“The query completed without returning rows.” The query ran and returned nothing: a statement that changes data, or a SELECT that matched no rows.

A result wider than the page scrolls sideways.

Make a new database (Mac)

  1. In the Databases tab, click New Database in the inspector’s bar.
  2. Type a Name.
  3. Click Create.

The database is empty and appears in the list as “Not connected to a service”. To have a service use it, choose it under Database when you deploy a new version of the service: see Check your backend’s logs and deploys. Or ask your Agents in the Project’s chat.

New Database is only on the Mac, and it appears once the tab lists at least one database. For the app’s first database, ask your Agents. If creating fails, the sheet says why.

Delete a database

  1. In the Databases tab, touch and hold the database’s row (on the Mac, right-click it).
  2. Choose Delete Database.
  3. The app asks Delete Database?: “This permanently deletes the database and everything stored in it.” Choose Delete Database to confirm.

Delete Database is dimmed while a service uses the database (its row says In Use). The app has no button to disconnect a database from a service. Ask your Agents in the Project’s chat to do it, or remove the service if you no longer need it (see Host your app’s backend, database and sign-in (AirHost)).

If deleting fails, the app shows That Didn’t Work with the reason, and the database comes back to the list.

Questions

The page says “The database couldn't run this query.”
The database refused the statement. Check the SQL and the table and column names in it, then tap Run again.
The page says “The database's answer couldn't be read. Try again.”
The answer came back in a form the app couldn’t show. Tap Run again.
Another message appears under SQL
That’s the reason the query didn’t run. Fix what it says and tap Run again.
Tables shows an error instead of the tables
The list of tables couldn’t load. Tap Try Again. You can still type a query in SQL and run it.
Does removing a service delete its database?
No. The database, its data and your app users stay.
Can my Agents query the database?
Yes. They run SQL and create or delete databases with workers db. See workers. You can also ask them in the Project’s chat, for example to find one person’s rows or to explain a table.