LesSQL

LesSQL is a flutter plugin for sqlite.

Getting started

1.Import LesSQL

import 'package:lessql/lessql.dart';

2.Init databse

Define DB

class FooDB extends LesDB{

  @override
  String getName() {
    return 'foo_db';
  }

  @override
  int getVersion() {
    return 1;
  }

}

Define table

class FooTable1 extends LesTable{

  @override
  List<String> getColumnNames() {
    return ['c1','c2','c3','c4'];
  }

  @override
  List<String> getColumnTypes() {
    return [Contract.TYPE_NUMBER,Contract.TYPE_NUMBER,Contract.TYPE_NUMBER,Contract.TYPE_NUMBER,];
  }

  @override
  String getTableName() {
    return 'table1';
  }
  @override
  List<int> getPrimaryColumnIndexes() {
    return [1];
  }

  @override
  String getAutoIncrementID(){
    return "id";
  }
}

Init database

LesSQL.initLesDB(new FooDB(), [new FooTable1(),new FooTable2()]);

Insert

LesTable and LesEntity must correspond one-to-one

class FooEntity1 extends LesEntity{

  String c1;
  int c2;
  int c3;
  int c4;

  FooEntity1(this.c1,this.c2,this.c3,this.c4);

  @override
  List getValues() {
    return [c1,c2,c3,c4];
  }
}

Random random = new Random();
FooEntity1 entity1 = new FooEntity1(random.nextInt(10000).toString(),
                     random.nextInt(10000), 
                     random.nextInt(10000), 
                     random.nextInt(10000));
LesSQL.insert(new FooTable1(), entity1.getValues()).then(_updateDes);

License

   Copyright 2017 Qinglian.Zhang

   Licensed under the Apache License, Version 2.0 (the "License");
   you may not use this file except in compliance with the License.
   You may obtain a copy of the License at

     http://www.apache.org/licenses/LICENSE-2.0

   Unless required by applicable law or agreed to in writing, software
   distributed under the License is distributed on an "AS IS" BASIS,
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   See the License for the specific language governing permissions and
   limitations under the License.

Libraries

db
lessql

Dart

dart:ui
Built-in types and core primitives for a Flutter application. [...]

Core

dart:async
Support for asynchronous programming, with classes such as Future and Stream. [...]
dart:collection
Classes and utilities that supplement the collection support in dart:core. [...]
dart:convert
Encoders and decoders for converting between different data representations, including JSON and UTF-8. [...]
dart:core
Built-in types, collections, and other core functionality for every Dart program. [...]
dart:developer
Interact with developer tools such as the debugger and inspector. [...]
dart:math
Mathematical constants and functions, plus a random number generator. [...]
dart:typed_data
Lists that efficiently handle fixed sized data (for example, unsigned 8 byte integers) and SIMD numeric types. [...]

VM

dart:io
File, socket, HTTP, and other I/O support for non-web applications. [...]
dart:isolate
Concurrent programming using isolates: independent workers that are similar to threads but don't share memory, communicating only via messages. [...]