# set

The set() method for the SurrealDB Mojo SDK assigns a value as a parameter for this connection.

Assigns a value to a parameter for the connection, so you can reference it as `$name` in subsequent queries.

```python title="Method Syntax"
client.set(name, value_cbor, session)
```

## Arguments

<table>
    <thead>
        <tr>
            <th colspan="2" scope="col">Argument</th>
            <th colspan="2" scope="col">Description</th>
        </tr>
    </thead>
    <tbody>
        <tr>
            <td colspan="2" scope="row" data-label="Argument"><code>name</code></td>
            <td colspan="2" scope="row" data-label="Description">The parameter name, without the leading <code>$</code>.</td>
        </tr>
        <tr>
            <td colspan="2" scope="row" data-label="Argument"><code>value_cbor</code></td>
            <td colspan="2" scope="row" data-label="Description">The value, CBOR-encoded as a <code>List[UInt8]</code>.</td>
        </tr>
        <tr>
            <td colspan="2" scope="row" data-label="Argument"><code>session</code></td>
            <td colspan="2" scope="row" data-label="Description">An optional session id.</td>
        </tr>
    </tbody>
</table>

## Convenience wrappers

For common scalar types, the SDK provides wrappers that encode the value for you:

- `set_string(name, value, session)`
- `set_int(name, value, session)`
- `set_bool(name, value, session)`

## Example usage

```python
client.set_string("name", "Chiru")
client.set_int("age", 30)

var resp = client.query("SELECT * FROM person WHERE name = $name AND age >= $age;")
```

To encode a value by hand, use `CborCodec`:

```python
from surrealdb import CborCodec

var codec = CborCodec()
client.set("name", codec.encode_text("Chiru"))
```

## See also

- [`unset()`](/docs/reference/mojo/methods/unset.md)
