The SurrealDB SDK for Python has a SurrealDB
and AsyncSurrealDB
class that provides methods for querying a remote SurrealDB database.
These classes are designed to be simple to use and easy to understand for developers who are new to Python or SurrealDB.
This page lists out the methods that are available. Both classes have the same methods, the only difference is the addition of the async / await
keywords in the AsyncSurrealDB
class.
Method | Description |
---|---|
Surreal / AsyncSurreal | Connects to a local or remote database endpoint |
db.close() | Closes the persistent connection to the database |
db.use(namespace,database) | Switch to a specific namespace and database |
db.let(key,value) | Assigns a value as a variable for this connection |
db.unset(key) | Removes a variable for this connection |
Method | Description |
---|---|
db.query(sql,vars) | Runs a set of SurrealQL statements against the database |
db.select(thing) | Selects all records in a table, or a specific record |
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) | Kill a running live query |
Method | Description |
---|---|
db.create(thing,data) | Creates a record in the database |
db.insert(thing,data) | Inserts one or multiple records in the database |
db.update(thing,data) | Updates all records in a table, or a specific record |
db.merge(thing,data) | Modifies all records in a table, or a specific record |
db.patch(thing,data) | Applies JSON Patch changes to all records in a table, or a specific record |
db.delete(thing,data) | Deletes all records, or a specific record |
Method | Description |
---|---|
db.signup(vars) | Signs this connection up to a specific authentication scope |
db.signin(vars) | Signs this connection in to a specific authentication scope |
db.invalidate() | Invalidates the authentication for the current connection |
db.authenticate(token) | Authenticates the current connection with a JWT token |
db.info() | Returns the record of an authenticated scope user |