Questions tagged [sqflite]

Use this tag for questions about the plugin for flutter named sqflite - which enables storage, retrieval, and manipulation of SQLite databases via flutter code.

sqflite is an plugin for . Supports both and .

Package documentation: sqflite

902 questions
5
votes
7 answers

How to query the sqflite database using the LIKE statement and the % or * sql wildcard

I'm trying to query a Companies table using the companyName, I want to get the companies whose companyName(s) contains a query string, not only the companies whose companyName are exact matches of my query strings. If I was using sql, I would use…
Diligence Vagere
  • 178
  • 1
  • 3
  • 9
5
votes
1 answer

Flutter - How to update the table structure in Sqflite?

My app is in production and I want to manage user data when user updates the app without loss of their data, how can I achieve this with sqflite. Explicitly I want to add a column and delete another.
Mr Magloire
  • 773
  • 8
  • 14
4
votes
1 answer

Delete Database in Sqflite package in flutter

I am using the package 'sqflite' in flutter and I could not find a way to delete the entire database when the user in my app clicks on 'Delete Account'. There are methods to delete data in a table but is there a way to delete the entire database…
Vignesh Sekar
  • 76
  • 2
  • 7
4
votes
0 answers

Is this flutter (riverpod with sqfite) code optimal/correct for manual reordering a list? (code attached)

Is this flutter (riverpod/StateNotifier) code optimal/correct for the use case of manually re-ordering a list, and for which order is persisted in SQLite (using sqfite)? Being new to riverpod aspects I'm seeking clarity on: manually calculating…
Greg
  • 34,042
  • 79
  • 253
  • 454
4
votes
1 answer

Flutter - sqflite: How to change the order (index) of the persisted data?

I have searched for this question everywhere. Maybe I didn’t use the correct search terms. If it’s been asked already, my apologies. I’ll quickly delete this if it turns out to be a duplicate. I’m a rather inexperienced coder, so this code will…
Pedez
  • 41
  • 3
4
votes
3 answers

Flutter, Sqflite - DatabaseException(no such table: Project...)

So I have a class DBProvider, which is creating a new instance whenever it hasn't been initialized yet. The database currently contains 8 tables that are created in 1 query (the same thing happens when there is only 1 table). Then I'm trying to…
Jakub Kostka
  • 551
  • 2
  • 7
  • 20
4
votes
1 answer

Flutter pre-cache images

I'm working on a Flutter project where I want to pre-cache images at the start of the app. The idea is when you start the app the first time, it downloads a list of images either cache / stored in DB / stored in local storage / or any other viable…
4
votes
1 answer

How to model and load data from related tables using Sqflite

I have two related tables with a foreign key declared in my schema: CREATE TABLE Collection( id INTEGER PRIMARY KEY, name TEXT, start_date INT ); CREATE TABLE Item ( id INTEGER PRIMARY KEY, collection_id INTEGER, name…
unairoldan
  • 2,775
  • 4
  • 28
  • 49
4
votes
2 answers

Dismissible and FutureBuilder do not work together

It is kind of a complex problem but I'll do my best to explain it. My project utilizes a sqflite database. This particular page returns a list of Dismissible widgets according to the data in the database. This is how I read the data: class…
mominbay
  • 51
  • 4
4
votes
1 answer

Flutter SQFLite create multiple tables at once

I'm using the code below and want to know how this database function can be altered so that it creates two separate tables at once: static Future database() async { final dbPath = await sql.getDatabasesPath(); return…
Hasen
  • 11,710
  • 23
  • 77
  • 135
4
votes
1 answer

Transaction/batch in a newly created SQFlite database

The following only happens with the database just created as in the code. A previously existing database works all right. I have the usual singleton setup for the database helper, the relevant part being: Future get database async { //…
Gábor
  • 9,466
  • 3
  • 65
  • 79
4
votes
6 answers

Flutter DataBaseException(table category_Table has no column named category_id)

I`m trying to insert data from a json object ,the following code is a bout the table I used I defined the database helper class like this: class DatabaseHelper { static DatabaseHelper _databaseHelper; // Singleton DatabaseHelper static…
ElhamKeshavarz
  • 411
  • 2
  • 8
  • 19
4
votes
3 answers

Drop table and recreate if exist in sqflite flutter

I want to drop table before populating with server data if exist. the Queries I'm trying deleteOptionTable() async { final db = await database; db.rawDelete("Delete * from option"); } dropTable() async { final db = await…
Farhana Naaz Ansari
  • 7,524
  • 26
  • 65
  • 105
3
votes
0 answers

Flutter (IOS) SqfliteDatabaseException: DatabaseException(open_failed only on IOS 16.2

After upgrading to IOS 16.2 getting below exception when trying to access database. on IOS version 16.1 and below everything works fine. SqfliteDatabaseException: DatabaseException(open_failed…
Skandar Munir
  • 409
  • 5
  • 12
3
votes
1 answer

I/flutter ( 9532): Binding has not yet been initialized, when create database

I'm building an app with sqflite database, when I run my app i got this error: I/flutter ( 9532): eeeeeeeee Binding has not yet been initialized. I/flutter ( 9532): The "instance" getter on the ServicesBinding binding mixin is only available once…
Abdullah Bahattab
  • 612
  • 1
  • 16
  • 32