postgres 0.9.9

  • README.md
  • CHANGELOG.md
  • Installing
  • Versions
  • 90

postgres

Build Status codecov

A library for connecting to and querying PostgreSQL databases.

This driver uses the more efficient and secure extended query format of the PostgreSQL protocol.

Usage

Create PostgreSQLConnections and open them:

var connection = new PostgreSQLConnection("localhost", 5432, "dart_test", username: "dart", password: "dart");
await connection.open();

Execute queries with query:

List<List<dynamic>> results = await connection.query("SELECT a, b FROM table WHERE a = @aValue", substitutionValues: {
    "aValue" : 3
});

for (final row in results) {
  var a = row[0];
  var b = row[1];

} 

Return rows as maps containing table and column names:

List<Map<String, Map<String, dynamic>>> results = await connection.mappedResultsQuery(
  "SELECT t.id, t.name, u.name FROM t LEFT OUTER JOIN u ON t.id=u.t_id");

for (final row in results) {
  var tID = row["t"]["id"];
  var tName = row["t"]["name"];
  var uName = row["u"]["name"];
}

Execute queries in a transaction:

await connection.transaction((ctx) async {
    var result = await ctx.query("SELECT id FROM table");
    await ctx.query("INSERT INTO table (id) VALUES (@a:int4)", {
        "a" : result.last[0] + 1
    });
});

See the API documentation: https://www.dartdocs.org/documentation/postgres/latest.

Features and bugs

Please file feature requests and bugs at the issue tracker.

Changelog

0.9.9

  • Add full support for UUID columns.

0.9.8

  • Preserve error stacktrace on various query or transaction errors.
  • Read support for BYEA columns.

0.9.7

  • Adds Connection.mappedResultsQuery to return query results as a Map with keys for table and column names.

0.9.6

  • Adds Connection.notifications to listen for NOTIFY events (thanks @andrewst)
  • Adds better error reporting.
  • Adds support for JSONB columns.
  • Fixes issue when encoding UTF16 characters (thanks @andrewst)

0.9.5

  • Allow connect via SSL.

0.9.4

  • Fixed issue with buffer length

0.9.3

  • Fixed issue with UTF8 encoding

0.9.2

  • Bump for documentation

0.9.1

  • Added transactions: PostgreSQLConnection.transaction and PostgreSQLConnection.cancelTransaction.

0.9.0

  • Initial version

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  postgres: "^0.9.9"

2. Install it

You can install packages from the command line:

with pub:


$ pub get

with Flutter:


$ flutter packages get

Alternatively, your editor might support pub get or flutter packages get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


      import 'package:postgres/postgres.dart';
  
Version Uploaded Documentation Archive
0.9.9 Apr 6, 2018 Go to the documentation of postgres 0.9.9 Download postgres 0.9.9 archive
0.9.8 Mar 28, 2018 Go to the documentation of postgres 0.9.8 Download postgres 0.9.8 archive
0.9.7 Mar 19, 2018 Go to the documentation of postgres 0.9.7 Download postgres 0.9.7 archive
0.9.6 Oct 5, 2017 Go to the documentation of postgres 0.9.6 Download postgres 0.9.6 archive
0.9.5 Mar 15, 2017 Go to the documentation of postgres 0.9.5 Download postgres 0.9.5 archive
0.9.4+1 Dec 13, 2016 Go to the documentation of postgres 0.9.4+1 Download postgres 0.9.4+1 archive
0.9.4 Dec 6, 2016 Go to the documentation of postgres 0.9.4 Download postgres 0.9.4 archive
0.9.3 Nov 30, 2016 Go to the documentation of postgres 0.9.3 Download postgres 0.9.3 archive
0.9.2 Nov 21, 2016 Go to the documentation of postgres 0.9.2 Download postgres 0.9.2 archive
0.9.1 Oct 14, 2016 Go to the documentation of postgres 0.9.1 Download postgres 0.9.1 archive

All 12 versions...

Analysis

We analyzed this package on Jun 12, 2018, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.0.0-dev.60.0
  • pana: 0.11.3

Scores

Popularity:
Describes how popular the package is relative to other packages. [more]
81 / 100
Health:
Code health derived from static analysis. [more]
99 / 100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
100 / 100
Overall score:
Weighted score of the above. [more]
90
Learn more about scoring.

Platforms

Detected platforms: Flutter, other

Primary library: package:postgres/postgres.dart with components: io.

Suggestions

  • Fix analysis and formatting issues.

    Analysis or formatting checks reported 24 hints.

    Run dartfmt to format lib/src/binary_codec.dart.

    Run dartfmt to format lib/src/connection.dart.

    Similar analysis of the following files failed:

    • lib/src/connection_fsm.dart (hint)
    • lib/src/execution_context.dart (hint)
    • lib/src/query.dart (hint)
    • lib/src/query_cache.dart (hint)
    • lib/src/query_queue.dart (hint)
    • lib/src/server_messages.dart (hint)
    • lib/src/substituter.dart (hint)
    • lib/src/text_codec.dart (hint)
    • lib/src/transaction_proxy.dart (hint)
    • lib/src/types.dart (hint)
  • Package is pre-v1 release.

    While there is nothing inherently wrong with versions of 0.*.*, it usually means that the author is still experimenting with the general direction API.

  • Maintain an example.

    Create a short demo in the example/ directory to show how to use this package. Common file name patterns include: main.dart, example.dart or you could also use postgres.dart.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=1.19.0 <2.0.0
crypto ^2.0.0 2.0.3
dart2_constant ^1.0.0 1.0.1+dart2
Transitive dependencies
charcode 1.1.1
collection 1.14.10
convert 2.0.1
typed_data 1.1.5
Dev dependencies
coverage any
test >=0.12.0 <0.13.0