Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
ourweb4 opened this issue Aug 27, 2024 · 4 comments

Comments

@ourweb4
Copy link

ourweb4 commented Aug 27, 2024

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
Copy link
Owner

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
Copy link
Author

ourweb4 commented Aug 27, 2024

@dkliss
Copy link

dkliss commented Aug 28, 2024

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
Copy link
Author

ourweb4 commented Aug 28, 2024

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants
@simolus3 @ourweb4 @dkliss and others