• Start

Methods

connect

The connect() method for the SurrealDB Mojo SDK connects to a database endpoint.

Connects to a database endpoint. The URL scheme selects the transport (http, https, ws, or wss).

Method Syntax
client.connect(endpoint, connect_options)

Argument

Description

endpoint

The database endpoint to connect to, ending in

/rpc

.

connect_options

An optional

ConnectOptions

carrying the namespace, database, credentials, TLS setting, and wire format.

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.

Was this page helpful?