# live_query

The live_query() method for the SurrealDB Mojo SDK starts a live query on a table.

Starts a live query on a table and returns the query id as a string. Notifications arrive out of band and are queued by the transport; pull them out with `poll_notifications()`.

```python title="Method Syntax"
client.live_query(table, 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>table</code></td>
            <td colspan="2" scope="row" data-label="Description">The table to subscribe to.</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>

## Example usage

```python
var query_id = client.live_query("person")

var notifications = client.poll_notifications()
for ref in notifications:
    print(ref[].query_id, ref[].action)
```

To get the full `RpcResponse` instead of just the query id, use `live_raw(table, session)`.

> [!NOTE]
> Live queries run over a stateful WebSocket session. WebSocket support is rolling out. On the HTTP transport, the engine reports `live_queries=False` and the SDK raises an `UnsupportedFeatureError`.

## See also

- [Live queries](/docs/reference/mojo/concepts/live-queries.md)
- [`kill()`](/docs/reference/mojo/methods/kill.md)
