From 2de3e1fe379b775ff2af86f795375f9b7e05ad75 Mon Sep 17 00:00:00 2001 From: Alexandre Roux Date: Tue, 18 Jun 2024 08:18:07 +0200 Subject: [PATCH] [sqflite] doc --- packages_web/sqflite_common_ffi_web/README.md | 5 +++++ sqflite/doc/troubleshooting.md | 19 +++++++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/packages_web/sqflite_common_ffi_web/README.md b/packages_web/sqflite_common_ffi_web/README.md index cef6f498..2dd85fb6 100644 --- a/packages_web/sqflite_common_ffi_web/README.md +++ b/packages_web/sqflite_common_ffi_web/README.md @@ -72,6 +72,11 @@ var db = openDatabase(path); ``` ## Limitations +### Use the same web port when debugging + +The database is stored in the browser indexeddb. Like any other web storage, it is tied to the port. (i.e. localhost:8080 is different from localhost:8081). +When debugging, you should use the same port to keep the same indexeddb database. + ### No shared worker available When shared worker are not supported - for example in Android Chrome as of 2022-10-20 -, a basic web worker is used. diff --git a/sqflite/doc/troubleshooting.md b/sqflite/doc/troubleshooting.md index bbfe692b..01579602 100644 --- a/sqflite/doc/troubleshooting.md +++ b/sqflite/doc/troubleshooting.md @@ -315,6 +315,25 @@ You could get a more recent version using [`sqflite_common_ffi`](https://pub.dev You could then add [`sqlite3_flutter_libs`](https://pub.dev/packages/sqlite3_flutter_libs) for ios/android or include your own sqlite shared library for desktop or mobile (one for each platform). + +### Open error + +Such error is often reported with something similar to: + +```text +SqfliteFfiException(sqlite_error: 14, , open_failed: SqliteException(14): while opening the database, bad parameter or other API misuse, bad parameter or other API misuse (code 21)}) +``` + +Please check and ensure that: +- The database path is correct (please provide it in the bug report, best is to print it out to report it exactly as it is used) +- The parent folder exists (you should create it if it does not exist) +- The parent folder is writable (try to create a file in it if you still get the error). + +Solutions: +- Use the `path_provider` package to find the best location for you database (`getDatabasesPath()` is only relevant for Android) +- Build the database path properly (using `join` from the `path` package) +- Create the parent folder if it does not exist + ## Error in Flutter web Look at package [sqflite_common_ffi_web](https://pub.dev/packages/sqflite_common_ffi_web) for experimental Web support.