postgres 3.5.4 copy "postgres: ^3.5.4" to clipboard
postgres: ^3.5.4 copied to clipboard

PostgreSQL database driver. Supports binary protocol, connection pooling and statement reuse.

PostgreSQL client #

CI

A library for connecting to and querying PostgreSQL databases (see Postgres Protocol). This driver uses the more efficient and secure extended query format of the PostgreSQL protocol.

Usage #

Create a Connection:

  final conn = await Connection.open(Endpoint(
    host: 'localhost',
    database: 'postgres',
    username: 'user',
    password: 'pass',
  ));
copied to clipboard

Execute queries with execute:

  final result = await conn.execute("SELECT 'foo'");
  print(result[0][0]); // first row and first field
copied to clipboard

Named parameters, returning rows as map of column names:

  final result = await conn.execute(
    Sql.named('SELECT * FROM a_table WHERE id=@id'),
    parameters: {'id': 'xyz'},
  );
  print(result.first.toColumnMap());
copied to clipboard

Execute queries in a transaction:

  await conn.runTx((s) async {
    final rs = await s.execute('SELECT count(*) FROM foo');
    await s.execute(
      r'UPDATE a_table SET totals=$1 WHERE id=$2',
      parameters: [rs[0][0], 'xyz'],
    );
  });
copied to clipboard

See the API documentation: https://pub.dev/documentation/postgres/latest/

Connection pooling #

The library supports connection pooling (and masking the connection pool as regular session executor).

Custom type codecs #

The library supports registering custom type codecs (and generic object encoders) through theConnectionSettings.typeRegistry.

Streaming replication protocol #

The library supports connecting to PostgreSQL using the Streaming Replication Protocol. See Connection documentation for more info. An example can also be found at the following repository: postgresql-dart-replication-example

Other notes #

This library originally started as StableKernel's postgres library, but got a full API overhaul and partial rewrite of the internals.

Please file feature requests and bugs at the issue tracker.

356
likes
160
points
78.2k
downloads

Publisher

verified publisheragilord.com

Weekly Downloads

2024.09.07 - 2025.03.22

PostgreSQL database driver. Supports binary protocol, connection pooling and statement reuse.

Repository (GitHub)

Topics

#sql #db #database #postgres

Documentation

API reference

License

BSD-3-Clause (license)

Dependencies

async, buffer, charcode, collection, crypto, meta, pool, sasl_scram, stack_trace, stream_channel

More

Packages that depend on postgres