# execute

Canonical URL: https://developers.iagenify.com/sdk/ref/connected-storage/run/execute/
Language: en

`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.

Status: relational database · free · one statement

## Parameters {#parameters}

| Name | Type | Requirement | Description |
| --- | --- | --- | --- |
| `sql` | string | required | One statement. Missing → refused. |
| `params` | array |  | Bound values for the placeholders. Use these rather than building the string. |

```javascript
await 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.

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

// Always
sql: "SELECT * FROM users WHERE email = ?", params: [email]
```

## One statement, not a script {#one}

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 {#writes}

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

```javascript
// 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] });
```

## When the database refuses {#errors}

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.

- [tables](/sdk/ref/connected-storage/run/tables): Ce qu'il y a à interroger.
- [execute · write](/sdk/ref/connected-storage/run-write/execute): La même action, du côté écriture.
- [run()](/sdk/ref/connected-storage/run): Toutes les actions, les garde-fous et ce que chacune coûte.

```python
storage.run(
    action="execute",
    sql="SELECT id, email FROM users WHERE created_at > ? ORDER BY id DESC LIMIT ?",
    params=["2026-01-01", 20],
)
```

```python
# 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])
```

```python
# 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])
```
