home / skills / windmill-labs / windmill / write-script-postgresql
/system_prompts/auto-generated/skills/write-script-postgresql
This skill helps you craft PostgreSQL queries with proper parameterization, clear input naming, and safe execution across scripts and workflows.
npx playbooks add skill windmill-labs/windmill --skill write-script-postgresqlReview the files below or copy the command above to add this skill to your agents.
---
name: write-script-postgresql
description: MUST use when writing PostgreSQL queries.
---
## CLI Commands
Place scripts in a folder. After writing, run:
- `wmill script generate-metadata` - Generate .script.yaml and .lock files
- `wmill sync push` - Deploy to Windmill
Use `wmill resource-type list --schema` to discover available resource types.
# PostgreSQL
Arguments are obtained directly in the statement with `$1::{type}`, `$2::{type}`, etc.
Name the parameters by adding comments at the beginning of the script (without specifying the type):
```sql
-- $1 name1
-- $2 name2 = default_value
SELECT * FROM users WHERE name = $1::TEXT AND age > $2::INT;
```
This skill is required when writing PostgreSQL queries for scripts that will run on the platform. It enforces a clear pattern for parameter declaration and typed argument usage inside SQL statements. Use it to produce safe, maintainable queries that integrate with the platform's script deployment flow.
Arguments are passed into SQL using positional parameters like $1::{type}, $2::{type}, and so on. Human-friendly parameter names are declared in comments at the top of the script (no types in the comments). After writing scripts, generate metadata and deploy using the platform CLI commands to produce the required .script.yaml and lock files and push your scripts to the runtime.
How do I name parameters?
Add single-line comments at the top of the script like `-- $1 name1` or `-- $2 name2 = default_value`.
Do I need to specify types in the comments?
No. Types must be specified inline in the SQL using the $n::{type} syntax.