Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/stablekernel/postgresql-dart
Dart PostgreSQL driver: supports extended query format, binary protocol and statement reuse.
https://github.com/stablekernel/postgresql-dart
dart driver postgresql
Last synced: 2 months ago
JSON representation
Dart PostgreSQL driver: supports extended query format, binary protocol and statement reuse.
- Host: GitHub
- URL: https://github.com/stablekernel/postgresql-dart
- Owner: stablekernel
- License: bsd-3-clause
- Created: 2016-09-01T00:47:57.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2022-09-06T20:25:26.000Z (over 2 years ago)
- Last Synced: 2024-08-01T16:27:10.042Z (5 months ago)
- Topics: dart, driver, postgresql
- Language: Dart
- Homepage: https://www.dartdocs.org/documentation/postgres/latest
- Size: 305 KB
- Stars: 130
- Watchers: 9
- Forks: 35
- Open Issues: 38
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
- awesome-pubdev - postgres - PostgreSQL database driver. Supports statement reuse and binary protocol. (Database)
- awesome-dart - Postgres - A PostgreSQL database driver that uses the extended, binary protocol for more efficient and secure queries. (Database)
README
# postgres
[![Build Status](https://travis-ci.org/stablekernel/postgresql-dart.svg?branch=master)](https://travis-ci.org/stablekernel/postgresql-dart) [![codecov](https://codecov.io/gh/stablekernel/postgresql-dart/branch/master/graph/badge.svg)](https://codecov.io/gh/stablekernel/postgresql-dart)
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 `PostgreSQLConnection`s and `open` them:
```dart
var connection = PostgreSQLConnection("localhost", 5432, "dart_test", username: "dart", password: "dart");
await connection.open();
```Execute queries with `query`:
```dart
List> 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:
```dart
List>> 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:
```dart
await connection.transaction((ctx) async {
var result = await ctx.query("SELECT id FROM table");
await ctx.query("INSERT INTO table (id) VALUES (@a:int4)", substitutionValues: {
"a" : result.last[0] + 1
});
});
```See the API documentation: https://pub.dev/documentation/postgres/latest/
## Features and bugs
Please file feature requests and bugs at the [issue tracker][tracker].
[tracker]: https://github.com/stablekernel/postgresql-dart/issues