Guides

Longer explanations, with examples you can paste in and run. There are few screens to explain, on purpose: writing a short handler is the easy part now, so the product's job is to get you into the code quickly and then stay out of the way.

What a script has, without importing anything

Every parameter, in both languages

A script is def main(event) in Python or export default async function main(event) in TypeScript. Inside it, these are already there:

PythonTypeScriptWhat it is for
db["shop"].sql(statement, params) db.source("shop").sql(…) run SQL on the data source called shop
db["shop"].get(table, **where) · .all(table) .get(table, where) · .all(table) one row, or every row
with db["shop"].transaction(): .transaction(async (tx) => …) commit several statements together
secrets["NAME"] secrets.NAME the project's secrets
email(to, subject, body) email(to, subject, body) send an email when the run ends
download(name, content) download(name, content) offer a file to download in the browser
http(url, json=…) await http(url, {json}) call another service
to_csv(rows) · to_table(rows) toCsv(rows) · toTable(rows) rows as CSV, or as a text table
print(…) console.log(…) the run's output

In TypeScript, calls to db and http are awaited. Errors are QueryError from the database and HttpError when a request gets no answer.