View Source surreal_config (surreal v2.1.0)
Connection configuration module for SurrealDB Erlang.
surrealdb-uri-format
SurrealDB URI Format
The SurrealDB URI format is an unofficial way to represent connection information for accessing SurrealDB. It allows users to define various parameters necessary for establishing a connection to the database server.
This format has been adopted and enhanced from mylk, a SurrealDB driver for Ruby.
The URI format follows this format:
- Plain TCP: surrealdb://username:password@host:port/namespace/database
- TLS: surrealdb+tls://username:password@host:port/namespace/database
Scheme
This is the scheme used to identify SurrealDB connections. The optional "tls" part indicates that the connection should be made over TLS (Transport Layer Security), providing a secure and encrypted communication channel.
Credentials
The username and password to authenticate with the SurrealDB server.
Host
The hostname or IP address of the SurrealDB server.
Namespace
The name of the SurrealDB namespace that you want to use.
Database
The name of the SurrealDB database that you want to use.
Timeout
Timeout for the operations in milliseconds. Default is 5000
(5 seconds).
example-uri
Example URI
Default for SurrealDB: surrealdb://root:root@localhost:8000/test/test
surrealdb://root:root@localhost:8000/test/test?timeout=10000
Link to this section Summary
Functions
Parse SurrealDB URI.
Link to this section Types
-type connection_map() ::
#{host => string(),
username => string(),
password => string(),
namespace => string(),
database => string(),
port => non_neg_integer(),
tls => boolean(),
timeout => timeout()}.
Link to this section Functions
-spec parse(Uri :: nonempty_string()) -> {ok, connection_map()} | {error, atom(), term()}.
Parse SurrealDB URI.
1> surreal_config:parse("surrealdb://root:root@localhost:8000/test/test").
% {ok,#{database => "test",host => "localhost",namespace => "test",
% password => "root",port => 8000,timeout => 5000,
% tls => false,username => "root"}}