dart_postgres_wrapper 1.0.9

  • Readme
  • Changelog
  • Installing
  • 58

dart_postgres_wrapper #

A simple postgres database wrapper. Makes it easy to use postgres requests.

Available methods #

  • createConnection
  • createTable
  • drop
  • copy
  • replace
  • setPrimaryKey
  • setColType
  • select
  • insert
  • deleteAll

Example #

import 'package:dart_postgres_wrapper/dart_postgres_wrapper.dart';
import 'package:dart_postgres_wrapper/data_type.dart';

main(List<String> arguments) async {
  String host = 'localhost';
  int port = 5432;
  String db = 'test';
  String dbUser = 'dbUser';
  String dbPassword = 'Password';
  String tab = 'tab';
  var pg = new PG(host, port, db, dbUser, dbPassword, tab);
  await pg.createConnection();
  await pg.createTable([
    new FieldAndType('nomenklatura', 'text'),
    new FieldAndType('magazin', 'text'),
    new FieldAndType('summaProdazhTyisRub', 'text'),
    new FieldAndType('natsenkaTyisRub', 'text'),
    new FieldAndType('natsenkaProc', 'text'),

  await pg.copy('/opt/DataToImport2.csv', isCsv: true);

  await pg.replace('natsenkaProc', ',', '.');
  await pg.replace('natsenkaTyisRub', ',', '.');
  await pg.replace('summaProdazhTyisRub', ',', '.');

  await pg.setPrimaryKey();
  await pg.setColType('natsenkaProc', 'double precision');
  await pg.setColType('natsenkaTyisRub', 'double precision');
  await pg.setColType('summaProdazhTyisRub', 'double precision');

  print(await pg.select(whereIdFrom: 1, whereIdTo: 5));

1.0.0 #

  • Initial version, created by Stagehand

Use this package as a library

1. Depend on it

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

  dart_postgres_wrapper: ^1.0.9

2. Install it

You can install packages from the command line:

with pub:

$ pub get

with Flutter:

$ flutter pub get

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

3. Import it

Now in your Dart code, you can use:

import 'package:dart_postgres_wrapper/dart_postgres_wrapper.dart';
Describes how popular the package is relative to other packages. [more]
Code health derived from static analysis. [more]
Reflects how tidy and up-to-date the package is. [more]
Weighted score of the above. [more]
Learn more about scoring.

We analyzed this package on Jan 20, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.7.0
  • pana: 0.13.4

Health issues and suggestions

Document public APIs. (-1 points)

37 out of 37 API elements have no dartdoc comment.Providing good documentation for libraries, classes, functions, and other API elements improves code readability and helps developers find and use your API.

Fix lib/dart_postgres_wrapper.dart. (-3.93 points)

Analysis of lib/dart_postgres_wrapper.dart reported 8 hints, including:

line 19 col 18: Unnecessary new keyword.

line 27 col 12: Use isNotEmpty instead of length

line 28 col 11: DO use curly braces for all flow control structures.

line 77 col 10: Use isNotEmpty instead of length

line 78 col 9: DO use curly braces for all flow control structures.

Fix bin/main.dart. (-1.99 points)

Analysis of bin/main.dart reported 4 hints:

line 2 col 8: Unused import: 'package:dart_postgres_wrapper/data_type.dart'.

line 11 col 7: The value of the local variable 'from' isn't used.

line 12 col 7: The value of the local variable 'to' isn't used.

line 14 col 11: Unnecessary new keyword.

Format lib/data_type.dart.

Run dartfmt to format lib/data_type.dart.

Maintenance issues and suggestions

Homepage URL doesn't exist. (-20 points)

At the time of the analysis the homepage field https://stekolschikovv.github.io was unreachable.

Support latest dependencies. (-10 points)

The version constraint in pubspec.yaml does not support the latest published versions for 1 dependency (postgres).

The package description is too short. (-20 points)

Add more detail to the description field of pubspec.yaml. Use 60 to 180 characters to describe the package, what it does, and its target use case.

Package is getting outdated. (-10.96 points)

The package was last published 57 weeks ago.

Maintain an example. (-10 points)

Create a short demo in the example/ directory to show how to use this package.

Common filename patterns include main.dart, example.dart, and dart_postgres_wrapper.dart. Packages with multiple examples should provide example/README.md.

For more information see the pub package layout conventions.


Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.0.0 <3.0.0
csv ^4.0.1 4.0.3
postgres ^1.0.2 1.0.2 2.1.0
Transitive dependencies
charcode 1.1.2
collection 1.14.12
convert 2.1.1
crypto 2.1.4
typed_data 1.1.6
Dev dependencies
test ^1.0.0