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.
Method | Description |
---|---|
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 | Description | ||
---|---|---|---|
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. |
db.live('person') # Async await db.live('person')
.subscribe_live()
Returns a queue that receives notification messages from a running live query.
Method Syntaxdb.subscribe_live(query_uuid)
Arguments | Description | ||
---|---|---|---|
query_uuid required | The UUID of a running live query |
db.subscribe_live(UUID) # Async await db.subscribe_live(UUID)
.kill()
Kills a running live query by it’s UUID
Method Syntaxdb.kill(query_uuid)
Arguments | Description | ||
---|---|---|---|
queryUuid required | The UUID of the live query you wish to kill |
db.kill(query_uuid) # Async await db.kill(query_uuid)