dart_sql 0.0.7

  • Readme
  • Changelog
  • Example
  • Installing
  • 65

dart_sql [Work In Progress] #

A declarative SQL front end for any SQL libriary like moor:ffi or sqflite that enables you to construct queries that look like ...

SQL.select().from('aircraft').where('tail_number').contains('N%').orderBy('model').asc.toString()

Advantages #

  1. Exact knowledge of SQL syntax is unecessary, auto-competion will provide guidance
  2. No need to contruct cumbersome SQL strings
  3. Results in much clearner "pure-dart" code
  4. Does not require Flutter, can be used for CLI and Server applications of Dart

Examples #

  // SELECT * FROM aircraft
  SQL.select().from('aircraft').toString();

  // SELECT id, model, year FROM aircraft
  SQL.select(['id', 'model', 'year']).from('aircraft').toString();

  // INSERT INTO aircraft (model, year) VALUES ("SR22", "2014")
  Map<String, dynamic> values = {"model": "SR22", "year": "2014"};
  SQL.insert().into('aircraft').values(values).toString();

  // DELETE FROM aircraft WHERE model = "SR22"'
  SQL.delete().from('aircraft').where('model').eq("SR22").toString();

[0.0.1] - 12/05/2019 #

  • Initial Release - Limited functionality, proof of concept

[0.0.2] - 12/05/2019 #

  • Added support for DELETE queries

[0.0.3] - 12/05/2019 #

  • Added support for ORDER BY

[0.0.4] - 12/06/2019 #

  • Added support for INSERT

[0.0.5] - 12/07/2019 #

  • Added additional INSERT options

[0.0.6] - 12/07/2019 #

  • Added support for basic UPDATE scripts

[0.0.7] - 12/07/2019 #

  • Added WHERE support for UPDATE

example/main.dart

import 'package:dart_sql/dart_sql.dart';

void main() {
  // SELECT * FROM aircraft
  SQL.select().from('aircraft').toString();

  // SELECT id, model, year FROM aircraft
  SQL.select(['id', 'model', 'year']).from('aircraft').toString();

  // INSERT INTO aircraft (model, year) VALUES ("SR22", "2014")
  Map<String, dynamic> values = {"model": "SR22", "year": "2014"};
  SQL.insert().into('aircraft').values(values).toString();

  // DELETE FROM aircraft WHERE model = "SR22"'
  SQL.delete().from('aircraft').where('model').eq("SR22").toString();
}

Use this package as a library

1. Depend on it

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


dependencies:
  dart_sql: ^0.0.7

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_sql/dart_sql.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
44
Health:
Code health derived from static analysis. [more]
99
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
70
Overall:
Weighted score of the above. [more]
65
Learn more about scoring.

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

  • Dart: 2.8.2
  • pana: 0.13.8-dev

Health issues and suggestions

Document public APIs. (-1 points)

44 out of 44 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/src/sql_update_query.dart. (-0.50 points)

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

line 1 col 8: Unused import: 'package:dart_sql/src/sql_into.dart'.

Maintenance issues and suggestions

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

At the time of the analysis the homepage field https://aeyrium.com was unreachable.

Package is pre-v0.1 release. (-10 points)

While nothing is inherently wrong with versions of 0.0.*, it might mean that the author is still experimenting with the general direction of the API.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.5.0 <3.0.0
Dev dependencies
test ^1.6.0