simolus3 / drift

Drift is an easy to use, reactive, typesafe persistence library for Dart & Flutter.
https://drift.simonbinder.eu/
MIT License
2.55k stars 365 forks source link

SqliteException (SqliteException(1): while preparing statement, no such table: word, SQL logic error (code 1) Causing statement: SELECT * FROM "word";) #3180

Open ourweb4 opened 3 weeks ago

ourweb4 commented 3 weeks ago

HI, I'm trying to write a database but it keeps giving me the above error.I think I created the database right way to my knowledge. Thanks

simolus3 commented 3 weeks ago

Well, how did you create the database then? Can you show some related snippets?

Some likely causes are:

  1. You're running the app on a desktop device and the database file you're using has already been created by another application, so drift didn't create the tables.
  2. You've added the words table after running the app with the initial database once, and didn't write a migration to upgrade the database and add the table.

But I'm going to need more information to provide meaningful help here.

ourweb4 commented 3 weeks ago

https://github.com/ourweb4/mva.git

dkliss commented 3 weeks ago

Hi, I keep on getting exact same error SqliteException(1): while preparing statement, no such table ... even when i see table created in .g file. I wiped my emulator data and still not use. Table exist after i run runner but no idea why i cannot use it. I tested on ios, android emulators as well as macos. Same error. I even tried to rename tables. This happens after i create new tables. I created a table before which is still working but any new separate tables created have below error, even when i see the name in .g database file. Also, primary key is assigned by me and not auto incremented key and am using companions.

Package version: drift: ^2.18.0

Causing statement: SELECT * FROM
 Error executing query: SqliteException(1): while preparing statement, no such table
QL logic error (code 1)
SqliteException(1): while preparing statement, no such table:
Causing statement: SELECT * FROM "

Example Table 

TextColumn get contactUniqueIdentifier =>
      text().customConstraint('NOT NULL UNIQUE')(); // Non-nullable and unique
  TextColumn get name => text()
      .withDefault(const Constant(''))(); // Nullable with default empty string
  TextColumn get type => text()
      .withDefault(const Constant(''))(); // Nullable with default empty string
  // Empty fields for future use
  TextColumn get emptyField1 => text()
      .withDefault(const Constant(''))(); // Nullable with default empty string
  TextColumn get emptyField2 => text()
      .withDefault(const Constant(''))(); // Nullable with default empty string
  TextColumn get emptyField3 => text()
      .withDefault(const Constant(''))(); // Nullable with default empty string
  @override
  Set<Column> get primaryKey => {uniqueIdentifier}; // Primary key
ourweb4 commented 3 weeks ago

Hi, Is there another package I can use for database other than drift? That will work please