postgres 1.0.0

  • README.md
  • CHANGELOG.md
  • Installing
  • Versions
  • 91

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

1.0.0

  • Adds support for Dart 2

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: ^1.0.0

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
1.0.0 Aug 6, 2018 Go to the documentation of postgres 1.0.0 Download postgres 1.0.0 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

All 13 versions...

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

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

  • Dart: 2.0.0
  • pana: 0.11.8

Platforms

Detected platforms: Flutter, other

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

Suggestions

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.

Format lib/src/binary_codec.dart.

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

Fix lib/src/connection.dart.

Analysis of lib/src/connection.dart reported 1 hint:

line 96 col 7: The value of the field '_secretKey' isn't used.

Fix additional 11 files with analysis or formatting issues.

Additional issues in the following files:

  • lib/src/connection_fsm.dart (Run dartfmt to format lib/src/connection_fsm.dart.)
  • lib/src/exceptions.dart (Run dartfmt to format lib/src/exceptions.dart.)
  • lib/src/execution_context.dart (Run dartfmt to format lib/src/execution_context.dart.)
  • lib/src/query.dart (Run dartfmt to format lib/src/query.dart.)
  • lib/src/query_cache.dart (Run dartfmt to format lib/src/query_cache.dart.)
  • lib/src/query_queue.dart (Run dartfmt to format lib/src/query_queue.dart.)
  • lib/src/server_messages.dart (Run dartfmt to format lib/src/server_messages.dart.)
  • lib/src/substituter.dart (Run dartfmt to format lib/src/substituter.dart.)
  • lib/src/text_codec.dart (Run dartfmt to format lib/src/text_codec.dart.)
  • lib/src/transaction_proxy.dart (Run dartfmt to format lib/src/transaction_proxy.dart.)
  • lib/src/types.dart (Run dartfmt to format lib/src/types.dart.)

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.0.0 <3.0.0
crypto ^2.0.0 2.0.6
Transitive dependencies
charcode 1.1.2
collection 1.14.11
convert 2.0.2
typed_data 1.1.6
Dev dependencies
coverage any
test ^1.3.0