SurrealDB Docs Logo

Enter a search query

Real-Time data streaming

You can use the SurrealDB Python SDK to create live queries that listen for changes in the database and automatically update your application when changes occur. This feature is useful for building real-time applications that need to respond to changes in the database.

MethodDescription
db.live(table, diff)Initiates a live query for a specified table name
db.subscribe_live(query_uuid)Returns a queue that receives notification messages from a running live query
db.kill(query_uuid)Kills a running live query by it’s UUID

.live()

Initiates a live query for a specified table name.

db.live(table, diff)

Arguments

ArgumentsDescription
table required

The table name to listen for changes for

diff optional

If set to true, live notifications will include an array of JSON Patch objects, rather than the entire record for each notification.

Example usage

db.live('person') # Async await db.live('person')

.subscribe_live()

Returns a queue that receives notification messages from a running live query.

Method Syntax
db.subscribe_live(query_uuid)

Arguments

ArgumentsDescription
query_uuid required

The UUID of a running live query

Example usage

db.subscribe_live(UUID) # Async await db.subscribe_live(UUID)

.kill()

Kills a running live query by it’s UUID

Method Syntax
db.kill(query_uuid)

Arguments

ArgumentsDescription
queryUuid required

The UUID of the live query you wish to kill

Example usage

db.kill(query_uuid) # Async await db.kill(query_uuid)