From b6e34755ace24fe3a8d3c76d54d33482afa209a5 Mon Sep 17 00:00:00 2001 From: Arun Date: Sun, 31 May 2020 18:35:29 +0530 Subject: [PATCH 1/8] Update README.md --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index be96904..7bc457c 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,7 @@ # Sqlite3 Arduino library for ESP32 +Note: This is a general purpose library based on the Sqlite codebase. For logging sensor data into database please use [Sqlite Micro Logger](https://github.com/siara-cc/sqlite_micro_logger_arduino), which is faster and memory efficient. + This library enables access to SQLite database files from SPIFFS or SD Cards through ESP32 SoC. Given below is a picture of a board that has a ready-made Micro SD slot (using SDMMC 4 bit mode - see example sqlite3_sdmmc): ![](ESP_WROOM_32_breakout.png?raw=true) From 98740e396333b6b4f8c370907defd22eb511531e Mon Sep 17 00:00:00 2001 From: jojo2357 <66704796+jojo2357@users.noreply.github.com> Date: Wed, 4 May 2022 17:40:02 -0600 Subject: [PATCH 2/8] Create CMakeLists This will allow users using CMake toolchains (like myself) to include this as a component. --- CMakeLists.txt | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 CMakeLists.txt diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..b34bc0d --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,14 @@ +set(COMPONENT_SRCDIRS + "src" + ) + +set(COMPONENT_ADD_INCLUDEDIRS + "src" + ) + +# Arduino-ESP32 core https://github.com/espressif/arduino-esp32 +set(COMPONENT_REQUIRES + "arduino-esp32" + ) + +register_component() From 0850945aa8f20504d4dc3ad3e9a7c36939e51fbc Mon Sep 17 00:00:00 2001 From: Arun Date: Tue, 5 Jul 2022 00:06:29 +0530 Subject: [PATCH 3/8] Fix for LittleFS and add example --- .../sqlite3_littlefs/sqlite3_littlefs.ino | 147 ++++++++++++++++++ src/esp32.cpp | 4 +- 2 files changed, 149 insertions(+), 2 deletions(-) create mode 100644 examples/sqlite3_littlefs/sqlite3_littlefs.ino diff --git a/examples/sqlite3_littlefs/sqlite3_littlefs.ino b/examples/sqlite3_littlefs/sqlite3_littlefs.ino new file mode 100644 index 0000000..6a821ba --- /dev/null +++ b/examples/sqlite3_littlefs/sqlite3_littlefs.ino @@ -0,0 +1,147 @@ +/* + This creates two empty databases, populates values, and retrieves them back + from the LITTLEFS file system +*/ +#include +#include +#include +#include +#include +#include "LittleFS.h" + +/* You only need to format LITTLEFS the first time you run a + test or else use the LITTLEFS plugin to create a partition + https://github.com/lorol/arduino-esp32fs-plugin/releases */ +#define FORMAT_LITTLEFS_IF_FAILED true + +const char* data = "Callback function called"; +static int callback(void *data, int argc, char **argv, char **azColName) { + int i; + Serial.printf("%s: ", (const char*)data); + for (i = 0; ifp); - if (fno == -1) + if (fno < 0) return SQLITE_IOERR_FSTAT; if (fstat(fno, &st)) return SQLITE_IOERR_FSTAT; @@ -433,7 +433,7 @@ static int ESP32Open( memset(&st, 0, sizeof(struct stat)); int rc = stat( zName, &st ); //Serial.println(zName); - if (rc == -1) { + if (rc < 0) { strcpy(mode, "w+"); //int fd = open(zName, (O_CREAT | O_RDWR | O_EXCL), S_IRUSR | S_IWUSR); //close(fd); From 8435103f34ad42e657d30d2f6627b9aa2432f91c Mon Sep 17 00:00:00 2001 From: "Arun (Arundale Ramanathan)" Date: Fri, 25 Nov 2022 18:26:36 +0530 Subject: [PATCH 4/8] Set default page size to 512 to avoid memory issues --- src/config_ext.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/config_ext.h b/src/config_ext.h index 1029cff..a26f1e5 100644 --- a/src/config_ext.h +++ b/src/config_ext.h @@ -10,7 +10,6 @@ #define SQLITE_DEFAULT_LOOKASIDE 512,64 #define YYSTACKDEPTH 20 #define SQLITE_SMALL_STACK 1 -#define SQLITE_DEFAULT_PAGE_SIZE 4096 #define SQLITE_SORTER_PMASZ 4 #define SQLITE_DEFAULT_CACHE_SIZE -1 #define SQLITE_DEFAULT_MEMSTATUS 0 @@ -25,7 +24,7 @@ #define SQLITE_LIKE_DOESNT_MATCH_BLOBS 1 #define SQLITE_DEFAULT_FOREIGN_KEYS 0 #define SQLITE_DEFAULT_LOCKING_MODE 1 -#define SQLITE_DEFAULT_PAGE_SIZE 4096 +#define SQLITE_DEFAULT_PAGE_SIZE 512 #define SQLITE_DEFAULT_PCACHE_INITSZ 8 #define SQLITE_MAX_DEFAULT_PAGE_SIZE 32768 #define SQLITE_POWERSAFE_OVERWRITE 1 From cbc44478a1bf00d2332a6c69050e16e03e5c7888 Mon Sep 17 00:00:00 2001 From: "Arun (Arundale Ramanathan)" Date: Fri, 25 Nov 2022 18:30:21 +0530 Subject: [PATCH 5/8] Fix sql length from 1000 to -1 --- .../sqlite3_stackoverflow_users.ino | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/sqlite3_stackoverflow_users/sqlite3_stackoverflow_users.ino b/examples/sqlite3_stackoverflow_users/sqlite3_stackoverflow_users.ino index ca5525b..14e2add 100644 --- a/examples/sqlite3_stackoverflow_users/sqlite3_stackoverflow_users.ino +++ b/examples/sqlite3_stackoverflow_users/sqlite3_stackoverflow_users.ino @@ -199,7 +199,7 @@ void setup(void) { } int step_res; if (sql.length() > 0) { - rc = sqlite3_prepare_v2(db1, sql.c_str(), 1000, &res, &tail); + rc = sqlite3_prepare_v2(db1, sql.c_str(), -1, &res, &tail); if (rc != SQLITE_OK) { String resp = F("Failed to fetch data: "); resp += sqlite3_errmsg(db1); @@ -251,7 +251,7 @@ void setup(void) { sql += server.arg("so_loc_count"); } } - rc = sqlite3_prepare_v2(db1, sql.c_str(), 1000, &res, &tail); + rc = sqlite3_prepare_v2(db1, sql.c_str(), -1, &res, &tail); if (rc != SQLITE_OK) { String resp = F("Failed to fetch data: "); resp += sqlite3_errmsg(db1); From caf273d231e5fbbc48d5c19aee9e702dcd81f68d Mon Sep 17 00:00:00 2001 From: "Arun (Arundale Ramanathan)" Date: Fri, 25 Nov 2022 18:31:16 +0530 Subject: [PATCH 6/8] Fix sql length from 1000 to -1 --- examples/sqlite3_web_console/sqlite3_web_console.ino | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/sqlite3_web_console/sqlite3_web_console.ino b/examples/sqlite3_web_console/sqlite3_web_console.ino index f34b9db..0702693 100644 --- a/examples/sqlite3_web_console/sqlite3_web_console.ino +++ b/examples/sqlite3_web_console/sqlite3_web_console.ino @@ -194,7 +194,7 @@ void setup ( void ) { //sql += "' and '"; //sql += server.arg("to"); //sql += "'"; - //rc = sqlite3_prepare_v2(db1, sql.c_str(), 1000, &res, &tail); + //rc = sqlite3_prepare_v2(db1, sql.c_str(), -1, &res, &tail); //if (rc != SQLITE_OK) { // String resp = "Failed to fetch data: "; // resp += sqlite3_errmsg(db1); @@ -218,7 +218,7 @@ void setup ( void ) { //} //sqlite3_finalize(res); - rc = sqlite3_prepare_v2(db1, sql.c_str(), 1000, &res, &tail); + rc = sqlite3_prepare_v2(db1, sql.c_str(), -1, &res, &tail); if (rc != SQLITE_OK) { String resp = "Failed to fetch data: "; resp += sqlite3_errmsg(db1); From 9f357090df8903e910a4bbfc7ef0c0a76eca5d72 Mon Sep 17 00:00:00 2001 From: "Arun (Arundale Ramanathan)" Date: Fri, 25 Nov 2022 18:32:16 +0530 Subject: [PATCH 7/8] Fix sql length from 1000 to -1 --- examples/sqlite3_webquery/sqlite3_webquery.ino | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/sqlite3_webquery/sqlite3_webquery.ino b/examples/sqlite3_webquery/sqlite3_webquery.ino index f2e7d24..2511781 100644 --- a/examples/sqlite3_webquery/sqlite3_webquery.ino +++ b/examples/sqlite3_webquery/sqlite3_webquery.ino @@ -167,7 +167,7 @@ void setup ( void ) { sql += "' and '"; sql += server.arg("to"); sql += "'"; - rc = sqlite3_prepare_v2(db1, sql.c_str(), 1000, &res, &tail); + rc = sqlite3_prepare_v2(db1, sql.c_str(), -1, &res, &tail); if (rc != SQLITE_OK) { String resp = "Failed to fetch data: "; resp += sqlite3_errmsg(db1); @@ -196,7 +196,7 @@ void setup ( void ) { sql += "' and '"; sql += server.arg("to"); sql += "'"; - rc = sqlite3_prepare_v2(db1, sql.c_str(), 1000, &res, &tail); + rc = sqlite3_prepare_v2(db1, sql.c_str(), -1, &res, &tail); if (rc != SQLITE_OK) { String resp = "Failed to fetch data: "; resp += sqlite3_errmsg(db1); From f4f401fbbb1a849528efdbe1dcf60326553bf860 Mon Sep 17 00:00:00 2001 From: "Arun (Arundale Ramanathan)" Date: Sun, 1 Oct 2023 15:46:51 +0530 Subject: [PATCH 8/8] Update library.properties --- library.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library.properties b/library.properties index 4ad3768..17a7317 100644 --- a/library.properties +++ b/library.properties @@ -1,5 +1,5 @@ name=Sqlite3Esp32 -version=2.3 +version=2.4 author=Arundale Ramanathan maintainer=Arun sentence=Sqlite3 database library for ESP32 core