Connects to a database endpoint. The URL scheme selects the transport (http, https, ws, or wss).
Method Syntax
client.connect(endpoint, connect_options)Arguments
Argument | Description |
|---|---|
endpoint | The database endpoint to connect to, ending in /rpc. |
connect_options | An optional ConnectOptionscarrying the namespace, database, credentials, TLS setting, and wire format. |
Example usage
from surrealdb import AsyncSurrealClient, ConnectOptions
from std.collections import Optional
def main():
var client = AsyncSurrealClient()
_ = client.connect(
"http://localhost:8000/rpc",
ConnectOptions(
namespace=Optional(String("test")),
database=Optional(String("test")),
access_token=Optional(String("Basic cm9vdDpyb290")),
),
)connect() returns a Bool.