Skip to content
Dart PostgreSQL driver: supports extended query format, binary protocol and statement reuse.
Dart Shell
Branch: master
Clone or download
isoos Missing substitution value no longer throws FormatException. (#113)
* Missing substitution value no longer throws FormatException.

* Fix test, as the table name is not resolveable
Latest commit 0b11ed2 Dec 5, 2019
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
ci Deleting ci/script.sh Nov 12, 2019
lib Missing substitution value no longer throws FormatException. (#113) Dec 5, 2019
test
.gitignore
.travis.yml Deleting ci/script.sh Nov 12, 2019
CHANGELOG.md Missing substitution value no longer throws FormatException. (#113) Dec 5, 2019
LICENSE
README.md Update README about the 2.0 branch. (#77) Nov 12, 2019
analysis_options.yaml Upgrade sources: Dart 2.2 format, pedantic + other strict linter rul… Nov 12, 2019
pubspec.yaml Missing substitution value no longer throws FormatException. (#113) Dec 5, 2019

README.md

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.

Development branch

The package's upcoming 2.0 version is being developed in the dev branch.

Features and bugs

Please file feature requests and bugs at the issue tracker.

You can’t perform that action at this time.