https://github.com/nopnop2002/esp32-idf-sqlite3
sqlite3 for esp-idf
https://github.com/nopnop2002/esp32-idf-sqlite3
esp-idf esp32 sqlite3
Last synced: about 1 year ago
JSON representation
sqlite3 for esp-idf
- Host: GitHub
- URL: https://github.com/nopnop2002/esp32-idf-sqlite3
- Owner: nopnop2002
- License: apache-2.0
- Created: 2024-02-22T20:43:11.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2025-04-07T12:29:11.000Z (about 1 year ago)
- Last Synced: 2025-04-07T13:30:50.691Z (about 1 year ago)
- Topics: esp-idf, esp32, sqlite3
- Language: C
- Homepage:
- Size: 19.2 MB
- Stars: 26
- Watchers: 2
- Forks: 5
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# esp32-idf-sqlite3
sqlite3 for esp-idf.
The original is [here](https://github.com/siara-cc/esp32-idf-sqlite3).
Although it is a very nice library, it cannot be built with ESP-IDF Ver5.
Therefore, We changed it so that it can also be used with ESP-IDF Ver5.
At the same time, we also changed the sample code so that it can be used with ESP-IDF Ver5.
# Software requirements
ESP-IDF V5.0 or later.
ESP-IDF V4.4 release branch reached EOL in July 2024.
# Changes from the original
- Change to local component
- Disable compile warnings
- Supports PSRAM
- Added fatfs/littlefs example
- Added tcp/websocket/mqtt/tusb example
- Added query/redirect/ftp example
- Moved sqllib.c and sqllib.h to components
# Installation
```
git clone https://github.com/nopnop2002/esp32-idf-sqlite3
cd esp32-idf-sqlite3/spiffs
idf.py menuconfig
idf.py flash monitor
```
# Using PSRAM
Enable PARAM using Menuconfig.

ESP32-S3 can now use two types: Quad Mode PSRAM and Octal Mode PSRAM.
Please check the ESP32-S3 data sheet to determine which type of PSRAM your ESP32S3 has.


sqlite uses CONFIG_SPIRAM to determine whether PSRAM is enabled or disabled.
If PSRAM is enabled, use ps_malloc()/ps_realloc() instead of malloc()/realloc().
```
#if CONFIG_SPIRAM
#define SQLITE_MALLOC(x) ps_malloc(x)
#define SQLITE_FREE(x) free(x)
#define SQLITE_REALLOC(x,y) ps_realloc((x),(y))
#else
#define SQLITE_MALLOC(x) malloc (x)
#define SQLITE_FREE(x) free(x)
#define SQLITE_REALLOC(x,y) realloc((x),(y))
#endif
```
If PSRAM is enabled, it will be automatically mounted at boot time.
- ESP32-CAM
```
I (224) esp_psram: Found 8MB PSRAM device
I (224) esp_psram: Speed: 40MHz
I (228) esp_psram: PSRAM initialized, cache is in low/high (2-core) mode.
W (235) esp_psram: Virtual address not enough for PSRAM, map as much as we can. 4MB is mapped
```
- ESP32-S3-WROOM-1 N4R2/N8R2/N16R2(Quad Mode)
```
I (172) esp_psram: Found 2MB PSRAM device
I (172) esp_psram: Speed: 40MHz
```
- ESP32-S3-WROOM-1 N4R8/N8R8/N8R8/N16R8(Octal Mode)
```
I (225) esp_psram: Found 8MB PSRAM device
I (230) esp_psram: Speed: 40MHz
```
# How to use this component in your project
Create idf_component.yml in the same directory as main.c.
```
YourProject --+-- CMakeLists.txt
+-- main --+-- main.c
+-- CMakeLists.txt
+-- idf_component.yml
```
Contents of idf_component.yml.
```
dependencies:
nopnop2002/sqlite3:
path: components/esp32-idf-sqlite3/
git: https://github.com/nopnop2002/esp32-idf-sqlite3.git
```
When you build a projects esp-idf will automaticly fetch repository to managed_components dir and link with your code.
```
YourProject --+-- CMakeLists.txt
+-- main --+-- main.c
| +-- CMakeLists.txt
| +-- idf_component.yml
+-- managed_components ----- nopnop2002__sqlite3
```