# insert

The insert() method for the SurrealDB Mojo SDK inserts one or more records into a table.

Inserts one or more records into a table. This is a convenience wrapper that runs `INSERT INTO <table> <data_json>;`.

```python title="Method Syntax"
client.insert(table, data_json, session, txn)
```

## 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>table</code></td>
            <td colspan="2" scope="row" data-label="Description">The table to insert into.</td>
        </tr>
        <tr>
            <td colspan="2" scope="row" data-label="Argument"><code>data_json</code></td>
            <td colspan="2" scope="row" data-label="Description">A single record or an array of records, as a JSON string.</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>
        <tr>
            <td colspan="2" scope="row" data-label="Argument"><code>txn</code></td>
            <td colspan="2" scope="row" data-label="Description">An optional transaction id.</td>
        </tr>
    </tbody>
</table>

## Example usage

```python
var resp = client.insert("person", '[{ "name": "Alice" }, { "name": "Bob" }]')
```

## Translated query

```surql
INSERT INTO $table $data_json;
```

## See also

- [`insert_relation()`](/docs/reference/mojo/methods/insert-relation.md)
