PostgreSQLConnection class

Instances of this class connect to and communicate with a PostgreSQL database.

The primary type of this library, a connection is responsible for connecting to databases and executing queries. A connection may be opened with open after it is created.

Implemented types

Constructors

PostgreSQLConnection(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.

Properties

allowClearTextPassword bool
If true, allows password in clear text for authentication.
final
databaseName String
Name of database this connection refers to.
final
encoding Encoding
no setter
hashCode int
The hash code for this object.
no setterinherited
host String
Hostname of database this connection refers to.
final
isClosed bool
Reports on the latest known status of the connection: whether it was open or failed for some reason.
no setter
isUnixSocket bool
If true, connection is made via unix socket.
final
messages Stream<ServerMessage>
Stream of server messages
no setter
notifications Stream<Notification>
Stream of notification from the database.
no setter
password String?
Password for authenticating this connection.
final
port int
Port of database this connection refers to.
final
processID int
The processID of this backend.
no setter
queryTimeoutInSeconds int
The default timeout for PostgreSQLExecutionContext's execute and query methods.
final
queueSize int
Returns this context queue size
no setterinherited
replicationMode ReplicationMode
The replication mode for connecting in streaming replication mode.
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
settings Map<String, String>
Settings values from the connected database.
final
socket Socket?
no setter
timeoutInSeconds int
The amount of time this connection will wait during connecting before giving up.
final
timeZone String
The timezone of this connection for date operations that don't specify a timezone.
final
username String?
Username for authenticating this connection.
final
useSSL bool
Whether or not this connection should connect securely.
final

Methods

addMessage(ClientMessage message) → void
Adds a Client Message to the existing connection
cancelTransaction({String? reason}) → void
Cancels a transaction on this context.
override
close() Future
Closes a connection.
execute(String fmtString, {Map<String, dynamic>? substitutionValues = const {}, int? timeoutInSeconds}) Future<int>
Executes a query on this context.
inherited
mappedResultsQuery(String fmtString, {Map<String, dynamic>? substitutionValues = const {}, bool? allowReuse, int? timeoutInSeconds}) Future<List<Map<String, Map<String, dynamic>>>>
Executes a query on this connection and returns each row as a Map.
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
open() Future
Establishes a connection with a PostgreSQL database.
query(String fmtString, {Map<String, dynamic>? substitutionValues, bool? allowReuse, int? timeoutInSeconds, bool? useSimpleQueryProtocol}) Future<PostgreSQLResult>
Executes a query on this context.
inherited
toString() String
A string representation of this object.
inherited
transaction(Future queryBlock(PostgreSQLExecutionContext connection), {int? commitTimeoutInSeconds}) Future
Executes a series of queries inside a transaction on this connection.

Operators

operator ==(Object other) bool
The equality operator.
inherited