Kismath Raheem
Kismath Raheem

Reputation: 21

Multiple tables in sqflite

im very new to flutter, and i just want to setup a SQLite database with multiple tables. my research below.

thanks in advance.

How to create multiple tables in a database in sqflite?

await db.execute('''
      create table $reminderTable (
        $columnReminderId integer primary key autoincrement,
        $columnReminderCarId integer not null,
        $columnReminderName text not null,
        $columnReminderNotifyMileage integer not null,
        $columnReminderEndMileage integer not null
       )''');
await db.execute('''
       create table $carTable (
        $columnCarId integer primary key autoincrement,
        $columnCarTitle text not null
       )''');

Unknown error calling sqlite3_step (10: disk I/O error) rs

Upvotes: 1

Views: 2750

Answers (1)

Anirban
Anirban

Reputation: 11

You can just combine multiple db.execute calls for example

void _createDb(Database db, int newVersion) async {
    await db.execute(
        'CREATE TABLE $noteTable($colId INTEGER PRIMARY KEY AUTOINCREMENT, $colTitle TEXT, '
        '$colDescription TEXT, $colPriority INTEGER, $colDate TEXT)');

 await db.execute(
        'CREATE TABLE $noteTable($colId INTEGER PRIMARY KEY AUTOINCREMENT, $colTitle TEXT, '
        '$colDescription TEXT, $colPriority INTEGER, $colDate TEXT)');
  }

Upvotes: 1

Related Questions