title: What is Causing this Dart Sq3Lite Database Exception Error?
body: <p>Thank you in advance for your help.</p>
  
  <p>This issue has been driving me crazy for the past couple of days. I have searched every site that Google has returned and still the resolutions haven't helped.</p>
  
  <p>I am attempting to create a Sq3Lite database using Dart and keeping getting a DatabaseException error when trying to create a table that uses foreign keys. I've tried turning foreign key use on with 'PRAGMA foreign_keys = ON' as well but no luck. I am also using an IOS simulator in Android Studio and delete the app before running the code with attempted fixes.</p>
  
  <p><strong>Here is my code:</strong></p>
  
  <pre><code>  final int version = 1;
    Database db;
  
    Future&lt;Database&gt; openDb() async {
      if (db == null) {
        db = await openDatabase(join(await getDatabasesPath(), 'skeema.db'), onCreate: (database, version) {
          database.execute('CREATE TABLE Account(id INTEGER PRIMARY KEY, Name TEXT NOT NULL, CurrencyType TEXT NOT NULL, ' + 'Balance REAL NOT NULL, IsPrimary TEXT NULL)');
          database.execute('CREATE TABLE BudgetItem(id INTEGER PRIMARY KEY, Name TEXT NOT NULL, Icon TEXT NOT NULL, Budget REAL NOT NULL, ' + 'IsPrimary TEXT NULL)');
          database.execute('CREATE TABLE TransactionType(id INTEGER PRIMARY KEY, Type TEXT NOT NULL)');
          database.execute('CREATE TABLE Transaction(id INTEGER PRIMARY KEY, Account_id INTEGER NOT NULL, BudgetItem_id INTEGER NOT NULL, ' +
              'TransactionType_id INTEGER NOT NULL, Amount REAL NOT NULL, Date TEXT NOT NULL, Party TEXT NOT NULL, Note TEXT NULL, ' +
              'FOREIGN KEY(Account_id) REFERENCES Account(id), ' +
              'FOREIGN KEY(BudgetItem_id) REFERENCES BudgetItem(id), ' +
              'FOREIGN KEY(TransactionType_id) REFERENCES TransactionType(id))');
        }, version: version);
      }
      return db;
    }
  </code></pre>
  
  <p><strong>Here is the error:</strong></p>
  
  <pre><code>[VERBOSE-2:ui_dart_state.cc(157)] Unhandled Exception: DatabaseException(Error Domain=FMDatabase Code=1 "near "Transaction": syntax error" UserInfo={NSLocalizedDescription=near "Transaction": syntax error}) sql 'CREATE TABLE Transaction(id INTEGER PRIMARY KEY, Account_id INTEGER NOT NULL, BudgetItem_id INTEGER NOT NULL, TransactionType_id INTEGER NOT NULL, Amount REAL NOT NULL, Date TEXT NOT NULL, Party TEXT NOT NULL, Note TEXT NULL, FOREIGN KEY(Account_id) REFERENCES Account(id), FOREIGN KEY(BudgetItem_id) REFERENCES BudgetItem(id), FOREIGN KEY(TransactionType_id) REFERENCES TransactionType(id))' args []}
  #0      wrapDatabaseException (package:sqflite/src/exception_impl.dart:11:7)
  &lt;asynchronous suspension&gt;
  #1      SqfliteDatabaseFactoryImpl.wrapDatabaseException (package:sqflite/src/factory_impl.dart:27:7)
  #2      SqfliteDatabaseMixin.safeInvokeMethod (package:sqflite_common/src/database_mixin.dart:208:15)
  #3      SqfliteDatabaseMixin.invokeExecute (package:sqflite_common/src/database_mixin.dart:370&lt;…&gt;
  </code></pre>
  
  <p>The first 3 tables get created successfully every time but the last table throws the error. Any help is greatly appreciated.</p>
  
  <p>Thank you.</p>