PostgreSQLConnection constructor
- String host,
- int port,
- String databaseName, {
- String? username,
- String? password,
- int timeoutInSeconds = 30,
- int queryTimeoutInSeconds = 30,
- String timeZone = 'UTC',
- bool useSSL = false,
- bool isUnixSocket = false,
- bool allowClearTextPassword = false,
- ReplicationMode replicationMode = ReplicationMode.none,
- Encoding? encoding,
Creates an instance of PostgreSQLConnection.
host
must be a hostname, e.g. "foobar.com" or IP address. Do not include scheme or port.
port
is the port to connect to the database on. It is typically 5432 for default PostgreSQL settings.
databaseName
is the name of the database to connect to.
username
and password
are optional if the database requires user authentication.
timeoutInSeconds
refers to the amount of time PostgreSQLConnection will wait while establishing a connection before it gives up.
queryTimeoutInSeconds
refers to the default timeout for PostgreSQLExecutionContext's execute and query methods.
timeZone
is the timezone the connection is in. Defaults to 'UTC'.
useSSL
when true, uses a secure socket when connecting to a PostgreSQL database.
allowClearTextPassword
when true, allows sending the password during authentication in clear text. Use only when required by the database server and under encrypted connections, this feature may lead to security issues.
Implementation
PostgreSQLConnection(
this.host,
this.port,
this.databaseName, {
this.username,
this.password,
this.timeoutInSeconds = 30,
this.queryTimeoutInSeconds = 30,
this.timeZone = 'UTC',
this.useSSL = false,
this.isUnixSocket = false,
this.allowClearTextPassword = false,
this.replicationMode = ReplicationMode.none,
Encoding? encoding,
}) : _encoding = encoding ?? utf8 {
_connectionState = _PostgreSQLConnectionStateClosed();
_connectionState.connection = this;
}