sqlbase 0.1.0 copy "sqlbase: ^0.1.0" to clipboard
sqlbase: ^0.1.0 copied to clipboard

SQLBase is a lightweight Flutter plugin that enables seamless communication between a Flutter app and an SQL database through a simple PHP back-end

example/lib/main.dart

import 'package:flutter/material.dart';

import 'package:sqlbase/sqlbase.dart';

void main() {
  Sqlbase.initialize(url: "http://localhost/sqlbase2.php", key: '123456');
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Home(),
    );
  }
}

class Home extends StatelessWidget {
  Home({super.key});

  final Sqlbase myDB = Sqlbase();

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(),
      body: Center(
        child: ElevatedButton(
            onPressed: ()async{
              Sqlbase.initialize(url: "http://localhost/sqlbase2.php", key: '123456');
              var data = await Sqlbase.rawQuery("Select * from items").execute();
              // SqlBaseResponse data = await myDB.fetchAll([
              // FetchTable('vw_report_trial_balance',where: {"storeid":"07616f5b-36a4-4fcd-b296-28c8e0dcbd14"}),
              //     FetchTable('vw_report_items',where: {"storeid":"07616f5b-36a4-4fcd-b296-28c8e0dcbd14"}),
              // ]);
              print(data);
              if(data.statusCode !=200)return;
            },
            child: Text('Try')),
      ),
    );
  }
}









createTable(){
  Sqlbase.createTable([
    SQLTable(
      name:"Users",
      column: [
        TableColumn("id",type: DataType.int,length:11,isPrimary:true,autoIncrement:true),
        TableColumn("name",type: DataType.varChar,length:225),
        TableColumn("email",type: DataType.varChar,length:225),
        TableColumn("createddate",type: DataType.date),
      ]
    ),
    SQLTable(
        name:"Business",
        column: [
          TableColumn("id",type: DataType.int,isPrimary:true,autoIncrement:true),
          TableColumn("userid",type: DataType.int,foreignKey:'Users.id',autoIncrement:true),
          TableColumn("name",type: DataType.varChar),
          TableColumn("address",type: DataType.varChar),
          TableColumn("createddate",type: DataType.date),
        ]
    ),
  ]);
}









createRecordEasy() async {
  Sqlbase myDB = Sqlbase();
  var data = await myDB.table('user').add({'name': "Sammed", 'country': 'Ghana'});
  if (data.statusCode != 200) {
  }
}

createRecordManyEasy() async {
  Sqlbase myDB = Sqlbase();
  var data = await myDB.table('user').addMany([
    {'name': "Sammed", 'country': 'Ghana'},
    {'name': "Ronaldo", 'country': 'Portugal'},
    {'name': "MBS", 'country': 'Saudi Arabia'}
  ]);
  if (data.statusCode != 200) {
  }
}

updateRecordEasy() async {
  Sqlbase myDB = Sqlbase();
  var data = await myDB.table('user').record(1, column: 'id').update(
    {'name': "Sammed", 'from': 'Ghana'},
  );
  if (data.statusCode != 200) {
  }
}

deleteRecordEasy() async {
  Sqlbase myDB = Sqlbase();
  var data = await myDB.table('user').record(1, column: 'id').delete();
  if (data.statusCode != 200) {
  }
}
0
likes
80
points
15
downloads

Publisher

unverified uploader

Weekly Downloads

SQLBase is a lightweight Flutter plugin that enables seamless communication between a Flutter app and an SQL database through a simple PHP back-end

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (license)

Dependencies

flutter, flutter_web_plugins, http, path, plugin_platform_interface, web

More

Packages that depend on sqlbase

Packages that implement sqlbase