run · read

execute

storage.run({ action: "execute", sql, params })

Runs one statement against a relational database and returns its rows. The same action writes — which is why the statement, not the name, is what to judge.

relational databasefreeone statement
Using Python?

Switch any code block to Python: the choice applies to every page. Python SDK guide and resource reference.

Parameters

sqlstringrequired

One statement. Missing → refused.

paramsarray

Bound values for the placeholders. Use these rather than building the string.

await storage.run({
  action: "execute",
  sql: "SELECT id, email FROM users WHERE created_at > ? ORDER BY id DESC LIMIT ?",
  params: ["2026-01-01", 20],
});
storage.run(
    action="execute",
    sql="SELECT id, email FROM users WHERE created_at > ? ORDER BY id DESC LIMIT ?",
    params=["2026-01-01", 20],
)
Use params, always

A value concatenated into the statement is a value that can end the statement and start another. Placeholders are not a style preference here — they are the difference between a query and an injection.

// Never
sql: `SELECT * FROM users WHERE email = '${email}'`

// Always
sql: "SELECT * FROM users WHERE email = ?", params: [email]
# Never
storage.run(action="execute", sql=f"SELECT * FROM users WHERE email = '{email}'")

# Always
storage.run(action="execute", sql="SELECT * FROM users WHERE email = ?", params=[email])

One statement, not a script

Several statements in one call are refused. One statement is one thing that can be judged — by a guard, by a permission prompt, by you reading a log — and a batch where only the first is examined is a guard that does not guard.

It writes too

A statement that changes data runs through this same action and comes back with its effect rather than rows. See execute (write) — and note that a guard keyed on the action name cannot tell the two apart.

// Reading
const rows = await storage.run({ action: "execute", sql: "SELECT …" });

// Writing — the same action
await storage.run({ action: "execute", sql: "UPDATE users SET … WHERE id = ?", params: [id] });
# Reading
rows = storage.run(action="execute", sql="SELECT …")

# Writing — the same action
storage.run(action="execute", sql="UPDATE users SET … WHERE id = ?", params=[row_id])

When the database refuses

Its own message comes back, so a rejected statement reads as the database explained it. That is deliberate: a bare status for a syntax error tells you nothing you can act on.