Data tables
Full-code apps can access Windmill data tables by whitelisting them in raw_app.yaml. This gives your backend runnables direct SQL access to the specified tables.
Whitelisting tables
Add a data section to your raw_app.yaml:
summary: "My dashboard"
data:
datatable: "main"
tables:
- "users"
- "orders"
- "products"
schema: "app1"
Fields
| Field | Type | Description |
|---|---|---|
data.datatable | string | The datatable name from your workspace settings |
data.tables | string[] | List of table names the app can access |
data.schema | string | Schema name within the datatable (isolates tables per app) |
Reference format
Data table references follow this format:
| Format | Description |
|---|---|
<datatable> | Reference the datatable itself |
<datatable>/<table> | Reference a specific table |
<datatable>/<schema>:<table> | Reference a table in a specific schema |
Accessing tables from backend runnables
Backend runnables can query whitelisted tables using SQL. The database connection is available through the datatable resource:
// backend/get_users.ts
export async function main(limit: number = 10) {
const result = await Bun.sql`SELECT * FROM app1.users LIMIT ${limit}`;
return result;
}
Or with PostgreSQL:
-- backend/get_orders.pg.sql
SELECT * FROM app1.orders
WHERE status = $1
ORDER BY created_at DESC
LIMIT $2;
On a data table under roles, a runnable that names no role connects with the roles of the identity the app runs as, the publisher in publisher mode. An inline runnable that reads data as the viewer connects with the roles of the person using the app instead, so row-level security policies can return different rows to each viewer.
Schema setup
When creating a new app with wmill app new, the CLI can optionally create a dedicated schema for your app's tables. SQL migration files are placed in sql_to_apply/:
sql_to_apply/
├── README.md
└── 000_create_schema_app1.sql
During development (wmill app dev), the dev server shows a modal to apply pending SQL migrations.
DATATABLES.md
The wmill app generate-agents command generates a DATATABLES.md file documenting the available tables and their schemas. This file is used by AI coding agents to understand your data model.