Connection Parameters
The EdgeDBClient
constructor can consume an EdgeDBConnection
class
containing connection arguments for the client.
Most of the time, the connection arguments are implicitly resolved via
projects. In other cases, the EdgeDBConnection
class exposes ways to construct connection arguments.
Connection builder
You can use a provided builder by calling the builder()
method on
EdgeDBConnection
var builder = EdgeDBConnection.builder();
The builder has the following methods:
Name |
Type |
Description |
---|---|---|
|
String |
The username to connect as. |
|
String |
The password used to authenticate. |
|
String |
The name of the database to use. |
|
String |
The hostname of the database. |
|
int |
The port of the database. |
|
String |
The TLS certificate authority, used to verify the server certificate. |
|
TLSSecurityMode |
The TLS security policy. |
Parse & constructor methods
EdgeDBConnection
also exposes static methods used to parse connection
arguments from different sources.
fromDSN
This method parses a DSN string into an EdgeDBConnection
.
var connection = EdgeDBConnection
.fromDSN("edgedb://user:pass@host:port/db");
fromProjectFile
This method resolves connection arguments from an edgedb.toml
project file.
var connection = EdgeDBConnection
.fromProjectFile("~/myproject/edgedb.toml");
fromInstanceName
This method resolves the connection arguments for a given instance name.
var connection = EdgeDBConnection
.fromInstanceName("my_instance_name");
resolveEdgeDBTOML
This method is the default behaviour, it scans the current directory for
a edgedb.toml
project file, if none is found, the parent directory is
scanned recursivly until a project file is found; if none is found, a
FileNotFoundException
is raised.
var connection = EdgeDBConnection
.resolveEdgeDBTOML();
parse
The parse method will resolve the given arguments as well as apply environment variables to the connection, following the priority levels of arguments.
var connection = EdgeDBConnection
.parse("my_instance");