sqljs 2.0.0

  • README.md
  • CHANGELOG.md
  • Example
  • Installing
  • Versions
  • 0

sqljs.dart

A dart wrapper for kipken/sql.js

Usage

    import 'package:sqljs/sqljs.dart';

    main() {
      var db = new Database();
      var statement = """
        CREATE TABLE hello (a int, b char);
        INSERT INTO hello VALUES (0, 'hello');
        INSERT INTO hello VALUES (1, 'world');
      """;
      db.run(statement);
      var res = db.exec("SELECT * FROM hello");
      for (var value in res.first.values) {
        print('row: ${value[0]} ${value[1]}');
      }
    }

Generating

This package uses dart_js_facade_gen. To generate a library from the typescript definition file run:

dart_js_facade_gen lib/sqljs.d.ts > lib/sqljs.dart

Features and bugs

Please file feature requests and bugs at the issue tracker.

Changelog

0.0.1

  • Initial version

1.0.0

  • Publish and add to github

example/main.dart

import 'dart:html';
import 'dart:convert';
import 'dart:typed_data';
import 'package:sqllite/sqljs.dart';

InputElement uploadInput;
Database db;
main() {
  uploadInput = querySelector('#fileupload');
  uploadInput.onChange.listen(importDb);
}

importDb(evt) {
  final files = uploadInput.files;
  if (files.length == 1) {
    final file = files[0];
    final reader = new FileReader();
    reader.onLoadEnd.listen((e) {
      var upload = reader.result.toString().split(',').elementAt(1);
      var dbBytes = BASE64.decode(upload);
      fillDB(dbBytes);
    });
    reader.readAsDataUrl(file);
  }
}

fillDB(List<int> data) {
  db = new Database(new Uint8List.fromList(data));
  var output = db.exec('SELECT * from LIST_ITEM');
  for (var row in output[0].values) {
    print(row);
  }
}

Use this package as a library

1. Depend on it

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


dependencies:
  sqljs: ^2.0.0

2. Install it

You can install packages from the command line:

with pub:


$ pub get

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

3. Import it

Now in your Dart code, you can use:


import 'package:sqljs/sqljs.dart';
  
Version Uploaded Documentation Archive
2.0.0 Oct 19, 2016 Go to the documentation of sqljs 2.0.0 Download sqljs 2.0.0 archive
Popularity:
Describes how popular the package is relative to other packages. [more]
0
Health:
Code health derived from static analysis. [more]
0
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
0
Overall:
Weighted score of the above. [more]
0
Learn more about scoring.

The package version is not analyzed, because it does not support Dart 2. Until this is resolved, the package will receive a health and maintenance score of 0.

Analysis issues and suggestions

Support Dart 2 in pubspec.yaml.

The SDK constraint in pubspec.yaml doesn't allow the Dart 2.0.0 release. For information about upgrading it to be Dart 2 compatible, please see https://www.dartlang.org/dart-2#migration.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=1.8.0 <2.0.0