Skip to main content
Database assertions let you verify that API calls produce the expected side effects in your database. After sending a request, query the database and assert on the results.

Supported Databases

Security

Database assertions are disabled by default. Enable them with --allow-db:
The --allow-db flag is required for security. Database blocks execute arbitrary SQL queries, so you must explicitly opt in.

Syntax

Set the connection with a # @db directive on the request, then use a >>>db block after it: the SQL query first, then expect <column> <operator> <value> lines checked against the first row of the result:

Connection Strings

SQLite

PostgreSQL

MySQL

Use Cases

Verify record creation

Verify cascade deletes

Verify data transformation

Store database connection strings in environment variables: @dbUrl = {{$env(DATABASE_URL)}}. This keeps credentials out of test files and lets you target different databases per environment.
Last modified on October 19, 2026