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:orfile::memory:(?cache=shared/private): an in-memory databasefile:path.db,file:///absolute/path.db: a local filelibsql://host: a server over HTTPS (?tls=0for 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 overridesauth_token.
Types#
| Type | Definition | Description |
|---|---|---|
Target | type Target = LocalTarget | RemoteTarget |
Classes#
Functions#
parse_target#
parse_target(url, auth_token, tls) -> TargetWhere url points; ValueError when @libsql/client would
refuse it.
| Parameter | Type | Description |
|---|---|---|
url | str | |
auth_token | str | None | |
tls | bool | 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)