drivers/postgres library Independent SQL drivers
PostgreSQL connection pools for raw SQL runtimes and typed ORM sessions.
PostgresDriver owns its pool by default. PostgresDriver.borrow uses a caller-owned pool and leaves it open when the driver closes.
Classes
- AcquisitionOptions
- Limits waiting for a connection, including establishment and initialization. Cancellation after acquisition does not cancel the session callback.
- Backend
- Static engine identity used to constrain driver and transaction APIs.
- CancellationToken
- A cancellation request. Await the operation itself to observe its actual database outcome; completion can win a race with cancellation.
- Capabilities Independent SQL drivers
- Features a concrete driver can execute for its actual engine and platform.
-
Codec<
T> - Converts a typed Dart value to database storage and decodes it on reads.
- Codecs
- Built-in conversions for SQL scalar values, JSON, and exact numeric types.
- Decimal
- A finite base-ten value, independent of binary floating point.
-
Driver<
B extends Backend> Independent SQL drivers -
Owns or borrows connection resources for a specific engine
B. - ExecutionOptions
- Per-operation connection acquisition and statement execution controls.
- LocalDate
- A Gregorian calendar date, without a time or timezone. Year 0 is 1 BC; negative years use astronomical numbering.
- LocalDateTime
- Calendar date and wall-clock time, with no timezone or implied UTC instant.
- LocalTime
- A wall-clock time at microsecond resolution, including the endpoint 24:00. The fourth constructor argument is the full fractional second (0..999999).
- Mariadb
- Type marker for MariaDB drivers and sessions.
- Mysql
- Type marker for MySQL drivers and sessions.
- Postgres
- Type marker for PostgreSQL drivers and sessions.
- PostgresDriver
- Owns or borrows a PostgreSQL pool and leases one connection per callback.
- PostgresOptions
- Configuration for an owned PostgreSQL connection pool.
- SqlCommand
- SQL text and separately bound values. Values are never interpolated into SQL.
- SqlConnection Independent SQL drivers
- Execution port for one physical connection during an active driver lease.
- SqlCursor
- Bounded row retrieval tied to the connection lease that opened it.
- Sqlite
- Type marker for native and browser SQLite drivers and sessions.
- SqlJson
- A non-SQL-null JSON document. Its value may itself be JSON null. Drivers use this envelope for parsed JSON, including JSON string scalars.
- SqlReal
- Explicit floating-point SQL input. JavaScript cannot distinguish an integral double from int by runtime type; this preserves the SQL intention.
- SqlResult
- Raw row values and write metadata returned by a completed driver operation.
Enums
- DecimalRounding
- Rounding is explicit; exact rejects a non-zero discarded remainder.
- PostgresTls
- Transport encryption and server identity checks for PostgreSQL connections.
- SqlDialect
- SQL engine used for quoting, parameter syntax, and capability validation.
Extensions
- InstantPrecision on DateTime
- Explicit precision conversion for resolved UTC instants.
Functions
-
postgresTypeRegistry(
) → TypeRegistry - Native calendar values and UTC instants, without integer overflow. Local calendar types cover PostgreSQL's full finite range; UTC instants additionally respect Dart DateTime's range. Pass this registry to PoolSettings before borrowing a pool with PostgresDriver.borrow(temporal: true).
Exceptions / Errors
- OrmException
- An ORM failure with a stable machine-readable code and optional cause.
- PostgresFailure
- A server-reported error, preserving SQLSTATE and the original exception.
- SqlFailure
- Adapter classification. Retrying also requires a confirmed rollback and an explicitly repeatable application callback; these flags alone are not enough.