Skip to content

Query recipes

Use these focused paths when you already understand installation and snapshot generation. Examples are labeled by scope so an inline proof is not mistaken for a runnable application.

LevelScopeVerification
Inline proofA small query or API boundary inside a focused guideBacked by a package or documentation contract when it claims exact output
RecipeOne task with schema assumptions, compiler contract, rendered driver input, dialect notes, and sourceCompiled fixture plus focused runtime assertions
Runnable applicationSchema, config, generated evidence, adapter lifecycle, and broader capabilitiesService-free tests and a real-database suite

Construct queries

TaskExampleWhat it proves
Select with typed parametersYour first querySelected row fields and ordered parameters
Add optional filters or columnsConditional compositionExplicit structural branches and result shape
Insert several rows from Array.mapMulti-row insert recipeAutomatic comma separation, compiler evidence, and five rows of ordered parameters
Choose mapped arrays or sql.join()Explicit list controlsEmpty, dynamic, or custom-separator behavior
Escape static analysis deliberatelyDynamic SQLExplicit Query<unknown> boundary

Execute queries

TaskExampleWhat it proves
Execute and assert cardinalityExecutionall, one, maybeOne, cancellation, and deadlines
Use an existing poolExisting poolsApplication lifecycle remains application-owned
Prepare repeated query shapesPrepared queriesStable skeleton and bounded cardinality variants
Run an ordered batchBatchesOne lease, ordered results, and non-atomic default
Stream a large resultStreamingBackpressure and explicit cleanup
Validate decoded rowsResult validationStandard Schema checks after driver decoding

Move data and operate safely

TaskExampleWhat it proves
Choose multi-row SQL, batch, or native bulkBulk dataDifferent semantics and protocol capabilities
Trace query lifecycleObservabilityNeutral events, redaction, and OpenTelemetry
Route reads and retry transactionsRouting and retriesSemantic routing and bounded retry policy
Combine PostgreSQL and SQLiteMulti-database applicationSeparate grammar, config, evidence, and driver boundaries

Complete applications

For setup, generated evidence, runtime behavior, and database-backed tests in one place, use the PostgreSQL, MySQL, SQLite, or PostgreSQL plus SQLite application.

The source applications are exercised by the repository's example and real-database test gates. The pages link to their exact source files rather than presenting generated schema output as an application-facing API.

Released under the MIT License.