GitHub

API reference for config.

Settings of a libSQL client (Effect's LibsqlClientConfig): LibsqlClientConfig opens a database from a URL, LibsqlLiveConfig uses a client the caller owns.

URLs are those of @libsql/client, checked when the config is made:

  • :memory: or file::memory: (?cache=shared / private): an in-memory database
  • file:path.db, file:///absolute/path.db: a local file
  • libsql://host: a server over HTTPS (?tls=0 for HTTP, with an explicit port); https:// / http:// as they say. wss:// / ws:// are served over HTTPS / HTTP too, which sqld and Turso accept on the same address.
  • ?authToken=... on a remote URL overrides auth_token.

Types

TypeDefinitionDescription
Targettype Target = LocalTarget | RemoteTarget

Classes

Functions

parse_target

parse_target(url, auth_token, tls) -> Target

Where url points; ValueError when @libsql/client would refuse it.

ParameterTypeDescription
urlstr
auth_tokenstr | None
tlsbool | None

Returns Target

def parse_target(url: str, auth_token: str | None, tls: bool | None) -> Target:
    """Where ``url`` points; ``ValueError`` when ``@libsql/client`` would
    refuse it."""
    if url == _MEMORY:
        url = "file::memory:"
    parts = urlsplit(url)
    if not parts.scheme:
        raise ValueError(f"The URL {url!r} has no scheme (use file:, libsql:, https: or http:)")
    if parts.fragment:
        raise ValueError(f"URL fragments are not supported: {'#' + parts.fragment!r}")
    scheme = parts.scheme.lower()
    if scheme == "file":
        return _local(parts.path, parts.query, parts.netloc, parts.port)
    auth_token, tls = _remote_query(parts.query, auth_token, tls)
    http = _http_scheme(scheme, tls, parts.port)
    if parts.username is not None or parts.password is not None:
        raise ValueError(
            "This client does not support HTTP Basic authentication with a username and "
            'password. Use auth_token or the "authToken" URL query parameter.'
        )
    if not parts.hostname:
        raise ValueError(f"The URL {url!r} names no host")
    return RemoteTarget(f"{http}://{parts.netloc}{parts.path.rstrip('/')}", auth_token)