GithubHelp home page GithubHelp logo

spatialdude / usqlite Goto Github PK

View Code? Open in Web Editor NEW
85.0 85.0 18.0 6.15 MB

μSQLite library module for MicroPython

License: MIT License

CMake 0.01% Makefile 0.01% C 99.98% Shell 0.01%
micropython micropython-library micropython-module sqlite sqlite3

usqlite's People

Contributors

dpgeorge avatar jandriea avatar lehenbauer avatar scruss avatar spatialdude avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

usqlite's Issues

insert failed

esp32wroom32 micropython1.8
`Guru Meditation Error: Core 0 panic'ed (LoadProhibited). Exception was unhandled.
Core 0 register dump:
PC : 0x4023ffe7 PS : 0x00060130 A0 : 0x80166468 A1 : 0x3ffcdf40
A2 : 0x0015122d A3 : 0x3fff0198 A4 : 0x00000005 A5 : 0x00000001
A6 : 0x00000500 A7 : 0x3ffe4f18 A8 : 0x00000001 A9 : 0x00000001
A10 : 0x00000001 A11 : 0xffeaeddc A12 : 0x00151225 A13 : 0x00000000
A14 : 0x00000001 A15 : 0x00000544 SAR : 0x00000018 EXCCAUSE: 0x0000001c
EXCVADDR: 0x0015122d LBEG : 0x400014fd LEND : 0x4000150d LCOUNT : 0xfffffffc

ELF file SHA256: 79f4c1dccd211abb

Backtrace: 0x4023ffe4:0x3ffcdf40 0x40166465:0x3ffcdf60 0x40166fae:0x3ffce010 0x401676f5:0x3ffce060 0x40162eb8:0x3ffce080 0x4015245d:0x3ffce0a0 0x40158c4d:0x3ffce0c0 0x40158d7a:0x3ffce0e0 0x40161811:0x3ffce100 0x40161b82:0x3ffce130 0x401524a9:0x3ffce160 0x40158c4d:0x3ffce190 0x40158d4e:0x3ffce1b0 0x400d174f:0x3ffce1e0 0x400d1c3d:0x3ffce230 0x400d4529:0x3ffce280 0x401049ea:0x3ffce2d0 0x400e16de:0x3ffce320 0x400e1993:0x3ffce360 0x400e1c6b:0x3ffce3a0 0x400ec1c1:0x3ffce3e0 0x400ef11d:0x3ffce440 0x400fe7b1:0x3ffce510 0x400f841f:0x3ffcecd0 0x400f8597:0x3ffced10 0x400d0819:0x3ffced60 0x400d0e00:0x3ffced90 0x400d0773:0x3ffcede0 0x400d038f:0x3ffcee30 0x401524b6:0x3ffcee80 0x40158c4d:0x3ffceeb0 0x40158d7a:0x3ffceed0 0x40084a69:0x3ffceef0 0x4015253c:0x3ffcef90 0x40158c4d:0x3ffceff0 0x40158d7a:0x3ffcf010 0x40084a69:0x3ffcf030 0x4015253c:0x3ffcf0d0 0x40158c4d:0x3ffcf140 0x40158d7a:0x3ffcf160 0x40084a69:0x3ffcf180 0x4015253c:0x3ffcf220 0x40158c4d:0x3ffcf290 0x40158d7a:0x3ffcf2b0 0x40084a69:0x3ffcf2d0 0x4015253c:0x3ffcf370 0x40158c4d:0x3ffcf3d0 0x40158c76:0x3ffcf3f0 0x401810ff:0x3ffcf410 0x401814bd:0x3ffcf4a0 0x40181525:0x3ffcf4c0 0x4016a360:0x3ffcf4e0`

uSQLite running on RAM (in memory)

Hello, thank you for the great project.

I would like to use the uSQLite on the ESP32-S3 (8MB RAM, 32MB Flash), where the uSQLite database will have ~4MB. So to be faster the idea is to load all database to the RAM, and get (the selects) to the RAM database, and when need to write data (insert/update), write on disk database, syncing with the RAM database.

Is possible to copy entire database to the RAM and use uSQLite on RAM e when needed insert/update data, write that specific data to disc, like SQLite support?

Should be like this (https://stackoverflow.com/a/53253110):

import sqlite3

source = sqlite3.connect('existing_db.db')
dest = sqlite3.connect(':memory:')
source.backup(dest)

and/or this (https://stackoverflow.com/a/53253110):

# first connection
c1 = sqlite3.connect("file::memory:?cache=shared", uri=True)

# second connection, to the *same database*
c2 = sqlite3.connect("file::memory:?cache=shared", uri=True)

# third connection, to a different database altogether
c3 = sqlite3.connect('/tmp/sqlite3.db', uri=True)
# can attach to the shared in-memory database, but only if you used
# uri=True on the original connection
c3.execute("ATTACH DATABASE 'file::memory:?cache=shared' AS inmem")

Thank you in advance!

compiling don't work with RP4 for the pico

Hi,

i want to compile micropython for pico. but the last step don't work. Have anyone a idea why it don't work?

make USER_C_MODULES=/home/pi/my_mpModules/micropython.cmake
[ -d build-PICO ] || cmake -S . -B build-PICO -DPICO_BUILD_DOCS=0 -DMICROPY_BOARD=PICO -DUSER_C_MODULES=/home/pi/my_mpModules/micropython.cmake
PICO_SDK_PATH is /home/pi/micropython/lib/pico-sdk
Defaulting PICO_PLATFORM to rp2040 since not specified.
Defaulting PICO platform compiler to pico_arm_gcc since not specified.
PICO compiler is pico_arm_gcc
CMake Error at /home/pi/micropython/lib/pico-sdk/cmake/preload/toolchains/find_compiler.cmake:28 (message):
Compiler 'arm-none-eabi-gcc' not found, you can specify search path with
"PICO_TOOLCHAIN_PATH".
Call Stack (most recent call first):
/home/pi/micropython/lib/pico-sdk/cmake/preload/toolchains/pico_arm_gcc.cmake:20 (pico_find_compiler)
/usr/share/cmake-3.18/Modules/CMakeDetermineSystem.cmake:93 (include)
CMakeLists.txt:50 (project)

CMake Error: CMake was unable to find a build program corresponding to "Unix Makefiles". CMAKE_MAKE_PROGRAM is not set. You probably need to select a different build tool.
CMake Error: CMAKE_C_COMPILER not set, after EnableLanguage
CMake Error: CMAKE_CXX_COMPILER not set, after EnableLanguage
-- Configuring incomplete, errors occurred!
make: *** [Makefile:18: all] Fehler 1

usqlite_Error: file is not a database

Good day

I get the following intermittent errors when running micropython (windows port, dev and standard variants) with the attached script.

usqlite_Error: database disk image is malformed
usqlite_Error: file is not a database

Sometimes it runs through successfully, but fails most of the time.

Sometimes it fails with null reference exceptions in different parts of sqlite3.c, so might be a loose pointer or buffer overflow?

usqlite_demo.zip

Regards

not work on micropython 8266

xtensa-lx106-elf-ld: build-GENERIC/firmware.elf section `.text' will not fit in region `iram1_0_seg'
xtensa-lx106-elf-ld: region `iram1_0_seg' overflowed by 398353 bytes
build-GENERIC/usqlite/usqlite_cursor.o:(.text.usqlite_cursor_execute+0x44): undefined reference to `atoi'
build-GENERIC/usqlite/usqlite_cursor.o: In function `usqlite_cursor_execute':
usqlite_cursor.c:(.text.usqlite_cursor_execute+0x22c): undefined reference to `atoi'
build-GENERIC/usqlite/usqlite.o: In function `sqlite3ShadowTableName':
usqlite.c:(.text.sqlite3ShadowTableName+0x13): undefined reference to `strrchr'
build-GENERIC/usqlite/usqlite_file.o:(.text.usqlite_file_exists+0xc): undefined reference to `strrchr'
build-GENERIC/usqlite/usqlite_file.o: In function `usqlite_file_exists':
usqlite_file.c:(.text.usqlite_file_exists+0x42): undefined reference to `strrchr'
usqlite_file.c:(.text.usqlite_file_exists+0x5a): undefined reference to `strrchr'
make: *** [Makefile:223: build-GENERIC/firmware.elf] Error 1

Compile for ESP32

I am trying to compile for esp32 target I am getting error:

/micropython/modules/usqlite/usqlite_file.c:113:37: error: 'mp_module_io' undeclared (first use in this function); did you mean 'mp_module_sys'?
     mp_obj_t open = usqlite_method(&mp_module_io, MP_QSTR_open);

usqlite does not compile

Hi!
I think there is a problem with the latest edits.. could you please check?
[ 98%] Building C object esp-idf/main/CMakeFiles/idf_main.dir//modules/usqlite/usqlite_vfs.c.obj
/home/ltomi91/Desktop/micro/micropythonrep/micropython/ports/esp32/modules/usqlite/usqlite_file.c: In function 'usqlite_file_exists':
/home/ltomi91/Desktop/micro/micropythonrep/micropython/ports/esp32/modules/usqlite/usqlite_file.c:36:19: error: implicit declaration of function 'mp_module_get'; did you mean 'mp_locals_get'? [-Werror=implicit-function-declaration]
mp_obj_t os = mp_module_get(MP_QSTR_uos);
^~~~~~~~~~~~~
mp_locals_get
/home/ltomi91/Desktop/micro/micropythonrep/micropython/ports/esp32/modules/usqlite/usqlite_file.c:36:19: warning: initialization of 'mp_obj_t' {aka 'void *'} from 'int' makes pointer from integer without a cast [-Wint-conversion]
/home/ltomi91/Desktop/micro/micropythonrep/micropython/ports/esp32/modules/usqlite/usqlite_file.c: In function 'usqlite_file_delete':
/home/ltomi91/Desktop/micro/micropythonrep/micropython/ports/esp32/modules/usqlite/usqlite_file.c:237:38: warning: passing argument 1 of 'usqlite_method' makes pointer from integer without a cast [-Wint-conversion]
mp_obj_t remove = usqlite_method(mp_module_get(MP_QSTR_uos), MP_QSTR_remove);
^~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /home/ltomi91/Desktop/micro/micropythonrep/micropython/ports/esp32/modules/usqlite/usqlite.h:35,
from /home/ltomi91/Desktop/micro/micropythonrep/micropython/ports/esp32/modules/usqlite/usqlite_file.c:25:
/home/ltomi91/Desktop/micro/micropythonrep/micropython/ports/esp32/modules/usqlite/usqlite_utils.h:47:48: note: expected 'const mp_obj_module_t *' {aka 'const struct _mp_obj_module_t *'} but argument is of type 'int'
mp_obj_t usqlite_method(const mp_obj_module_t *module, qstr name);
~~~~~~~~~~~~~~~~~~~~~~~^~~~~~
cc1: some warnings being treated as errors
make[3]: *** [esp-idf/main/CMakeFiles/__idf_main.dir/build.make:3431: esp-idf/main/CMakeFiles/idf_main.dir//modules/usqlite/usqlite_file.c.obj] Error 1
make[3]: *** Waiting for unfinished jobs....
make[3]: Leaving directory '/home/ltomi91/Desktop/micro/micropythonrep/micropython/ports/esp32/build-GENERIC'
make[2]: *** [CMakeFiles/Makefile2:4672: esp-idf/main/CMakeFiles/__idf_main.dir/all] Error 2
make[2]: Leaving directory '/home/ltomi91/Desktop/micro/micropythonrep/micropython/ports/esp32/build-GENERIC'
make[1]: *** [Makefile:149: all] Error 2
make[1]: Leaving directory '/home/ltomi91/Desktop/micro/micropythonrep/micropython/ports/esp32/build-GENERIC'
make failed with exit code 2
make: *** [Makefile:34: all] Error 2

Build failure esp32

First, my apologies for the verbose post(complete build output in zip file). As you can see below the build fails for esp32. Any direction will be appreciated.
Thanks,
Rick

FYI, I can build esp32 successfully without usqlite.

Ubuntu 20.04
Micropython 1.17
ESP-IDF v4.2

Project Structure
/Home
..../Micropython
..../Modules
......../usqlite
.........micropython.cmake
...
..../sqlite
....sqlite3.c
....sqlite3.h

micropython/ports/esp32$ make submodules
git submodule update --init ../../lib/berkeley-db-1.xx
micropython/ports/esp32$ make clean
idf.py -D MICROPY_BOARD=GENERIC -B build-GENERIC fullclean
Executing action: fullclean
Done
micropython/ports/esp32$ make USER_C_MODULES=/home/fredrick/micropython/modules/usqlite/micropython.cmake

[1283/1284] Linking CXX executable micropython.elf
FAILED: micropython.elf

...
build_failure.zip
...

collect2: error: ld returned 1 exit status
ninja: build stopped: subcommand failed.
ninja failed with exit code 1
make: *** [Makefile:34: all] Error 2
$

Possible memory leak

Good day

If I run the attached script (see below), tested on windows, unix and stm32f769 builds, it runs fine until the free memory drops below 5%, and then crashes with the error:

Traceback (most recent call last):
File "E:\scratch\micropython\mp_usqlite\samples\producer_consumer_sd.py", line 167, in
File "asyncio/core.py", line 1, in run
File "asyncio/core.py", line 1, in run_until_complete
File "E:\scratch\micropython\mp_usqlite\samples\producer_consumer_sd.py", line 91, in consume
usqlite_Error: error (26): file is not a database sql: 'SELECT COUNT(ID) from items;'
PS E:\scratch\micropython\mp_usqlite\micropython\ports\windows\build-dev>

If I run the script with useSqlite = False, the memory usage drops until about 1%, but the the gc kicks in and continues as expected.

Although, if useSqlite = True, when the memory usage drops to around 5%, the above error is displayed.
Might it be an issue in the interop between the gc and usqlite?

Regards

Script:

import uasyncio as asyncio
from queue import Queue
import gc
import os
import usqlite

Exception raised by get_nowait().

class QueueEmpty(Exception):
pass

Exception raised by put_nowait().

class QueueFull(Exception):
pass

class Queue:
def init(self, maxsize=0):
self.maxsize = maxsize
self._queue = []
self._evput = asyncio.Event() # Triggered by put, tested by get
self._evget = asyncio.Event() # Triggered by get, tested by put

def _get(self):
    self._evget.set()  # Schedule all tasks waiting on get
    self._evget.clear()
    return self._queue.pop(0)

async def get(self):  #  Usage: item = await queue.get()
    while self.empty():  # May be multiple tasks waiting on get()
        # Queue is empty, suspend task until a put occurs
        # 1st of N tasks gets, the rest loop again
        await self._evput.wait()
    return self._get()

def get_nowait(self):  # Remove and return an item from the queue.
    # Return an item if one is immediately available, else raise QueueEmpty.
    if self.empty():
        raise QueueEmpty()
    return self._get()

def _put(self, val):
    self._evput.set()  # Schedule tasks waiting on put
    self._evput.clear()
    self._queue.append(val)

async def put(self, val):  # Usage: await queue.put(item)
    while self.full():
        # Queue full
        await self._evget.wait()
        # Task(s) waiting to get from queue, schedule first Task
    self._put(val)

def put_nowait(self, val):  # Put an item into the queue without blocking.
    if self.full():
        raise QueueFull()
    self._put(val)

def qsize(self):  # Number of items in the queue.
    return len(self._queue)

def empty(self):  # Return True if the queue is empty, False otherwise.
    return len(self._queue) == 0

def full(self):  # Return True if there are maxsize items in the queue.
    # Note: if the Queue was initialized with maxsize=0 (the default) or
    # any negative number, then full() is never True.
    return self.maxsize > 0 and self.qsize() >= self.maxsize

event_test = asyncio.Event()
useSqlite = False

async def produce(queue):
icount = 0

while True:
    await queue.put(str(icount))  # Put result on queue        
    icount += 1
    await asyncio.sleep(.2)

async def consume(queue, dbConn):
while True:
await event_test.wait()

    while (queue.qsize() > 20):
        item = await queue.get()  # Blocks until data is ready            

print("Pulled item..." + str(item))

        if (useSqlite == True):
            dbConn.executemany(
                "BEGIN TRANSACTION;"
                f"INSERT INTO items VALUES ({item}, 0, '{item}', '{item}', False);"
                "COMMIT;")

            with dbConn.execute("SELECT COUNT(ID) from items;") as cur:
                for row in cur:
                    print("items count:", row[0])

            if (row[0] > 100):
                dbConn.executemany(
                    "BEGIN TRANSACTION;"
                    "DELETE FROM items;"
                    "COMMIT;")

        with open('sd/hello.txt', 'w+') as f:
             f.write(item)
        
        await asyncio.sleep(.1)

    event_test.clear()

async def watchQueue(queue):
while True:
if (queue.qsize() > 10):
event_test.set()

    await asyncio.sleep(1)

async def showQueueLength(queue):
while True:
print("Queue length..." + str(queue.qsize()))
await asyncio.sleep(2)

async def showMemUsage():
while True:
print(free(True))
await asyncio.sleep(5)

def free(full=False):
F = gc.mem_free()
A = gc.mem_alloc()
T = F+A
P = '{0:.2f}%'.format(F/T*100)
if not full: return P
else : return ('Total:{0} Free:{1} ({2})'.format(T,F,P))

def InitDb(clearDb = True):
dbconn = usqlite.connect("data.db")

if clearDb:
    dbconn.execute("DROP TABLE IF EXISTS items;")

    dbconn.execute('''CREATE TABLE IF NOT EXISTS items
                    (ID            INTEGER,
                    VERSION        INTEGER NOT NULL,
                    NAME           TEXT    NOT NULL,
                    DESCRIPTION    TEXT    NOT NULL,         
                    IS_COMPLETE    BOOL     NOT NULL);''')

    dbconn.execute("CREATE UNIQUE INDEX index_item_name ON items(name, description);")

return dbconn        

#os.rmdir('sd')
#os.mkdir('sd')
os.remove("data.db")

async def main():
queue = Queue()
dbConn = InitDb()
asyncio.create_task(produce(queue))
asyncio.create_task(consume(queue, dbConn))
asyncio.create_task(watchQueue(queue))
asyncio.create_task(showQueueLength(queue))
asyncio.create_task(showMemUsage())

print('Tasks are running...')
while True:
    await asyncio.sleep(5)

asyncio.run(main())

Success Raspberry Pi Pico RP2

No issues at all, even though not required it build successfully with btree and my other frozen libraries. Followed RP2 instructions, no changes were required...

[ 95%] Linking CXX executable firmware.elf
text data bss dec hex filename
654056 164 202416 856636 d123c /home/fredrick/micropython/ports/rp2/build-PICO/firmware.elf
[ 95%] Built target firmware
Scanning dependencies of target micropy_extmod_btree
[ 95%] Building C object CMakeFiles/micropy_extmod_btree.dir/home/fredrick/micropython/lib/berkeley-db-1.xx/btree/bt_close.c.obj
[ 96%] Building C object CMakeFiles/micropy_extmod_btree.dir/home/fredrick/micropython/lib/berkeley-db-1.xx/btree/bt_conv.c.obj
[ 96%] Building C object CMakeFiles/micropy_extmod_btree.dir/home/fredrick/micropython/lib/berkeley-db-1.xx/btree/bt_debug.c.obj
[ 96%] Building C object CMakeFiles/micropy_extmod_btree.dir/home/fredrick/micropython/lib/berkeley-db-1.xx/btree/bt_delete.c.obj
[ 97%] Building C object CMakeFiles/micropy_extmod_btree.dir/home/fredrick/micropython/lib/berkeley-db-1.xx/btree/bt_get.c.obj
[ 97%] Building C object CMakeFiles/micropy_extmod_btree.dir/home/fredrick/micropython/lib/berkeley-db-1.xx/btree/bt_open.c.obj
[ 97%] Building C object CMakeFiles/micropy_extmod_btree.dir/home/fredrick/micropython/lib/berkeley-db-1.xx/btree/bt_overflow.c.obj
[ 98%] Building C object CMakeFiles/micropy_extmod_btree.dir/home/fredrick/micropython/lib/berkeley-db-1.xx/btree/bt_page.c.obj
[ 98%] Building C object CMakeFiles/micropy_extmod_btree.dir/home/fredrick/micropython/lib/berkeley-db-1.xx/btree/bt_put.c.obj
[ 98%] Building C object CMakeFiles/micropy_extmod_btree.dir/home/fredrick/micropython/lib/berkeley-db-1.xx/btree/bt_search.c.obj
[ 99%] Building C object CMakeFiles/micropy_extmod_btree.dir/home/fredrick/micropython/lib/berkeley-db-1.xx/btree/bt_seq.c.obj
[ 99%] Building C object CMakeFiles/micropy_extmod_btree.dir/home/fredrick/micropython/lib/berkeley-db-1.xx/btree/bt_split.c.obj
[ 99%] Building C object CMakeFiles/micropy_extmod_btree.dir/home/fredrick/micropython/lib/berkeley-db-1.xx/btree/bt_utils.c.obj
[100%] Building C object CMakeFiles/micropy_extmod_btree.dir/home/fredrick/micropython/lib/berkeley-db-1.xx/mpool/mpool.c.obj
[100%] Built target micropy_extmod_btree
fredrick@fredrick-XPS-13-9370:~/micropython/ports/rp2$

help('modules')
main homie/node onewire uheapq
_boot homie/property rp2 uio
_onewire homie/validator ssd1306 ujson
_rp2 lib/ftp_thread uarray uos
_thread lib/inisetup uasyncio/init upip
_uasyncio lib/mqtt_as uasyncio/core upip_utarfile
builtins lib/primitives/init uasyncio/event urandom
cmath lib/primitives/delay_ms uasyncio/funcs ure
ds18x20 lib/primitives/message uasyncio/lock uselect
framebuf lib/primitives/pushbutton uasyncio/stream usqlite
gc lib/primitives/switch ubinascii ustruct
homie/init machine ucollections usys
homie/constants math uctypes utime
homie/device micropython uerrno uzlib
homie/network ntptime uhashlib
Plus any modules on the filesystem
import usqlite
if not usqlite.mem_status():
... usqlite.mem_status(True)
...
...
...
True
con = usqlite.connect("data.db")
con.executemany(
... "BEGIN TRANSACTION;"
... "CREATE TABLE IF NOT EXISTS data (name TEXT, year INT);"+
... "INSERT INTO data VALUES ('Larry', 1902);"+
... "INSERT INTO data VALUES ('Curly', 1903);"+
... "INSERT INTO data VALUES ('Moe', 1897);"+
... "INSERT INTO data VALUES ('Shemp', 1895);"+
... "COMMIT;")
<Cursor 'NULL'>

with con.execute("SELECT * from data") as cur:
... for row in cur:
... print("stooge:", row)
...
...
...
stooge: ('Larry', 1902)
stooge: ('Curly', 1903)
stooge: ('Moe', 1897)
stooge: ('Shemp', 1895)
con.close()
print("usqlite mem - current:", usqlite.mem_current(), "peak:", usqlite.mem_peak())
usqlite mem - current: 0 peak: 97296

RPI PICO is freezing

Hello!

I'm playing with an idea to use sqlite on microcontroller (RPI PICO). I've successfully built the firmware with usqlite module (with micropython v1.22.1)

When I execute the example script multiple times (from your README):

import usqlite

if not usqlite.mem_status():
    usqlite.mem_status(True) # Enable memory usage monitoring

con = usqlite.connect("data.db")

con.executemany(
    "BEGIN TRANSACTION;"
    "CREATE TABLE IF NOT EXISTS data (name TEXT, year INT);"+
    "INSERT INTO data VALUES ('Larry', 1902);"+
    "INSERT INTO data VALUES ('Curly', 1903);"+
    "INSERT INTO data VALUES ('Moe', 1897);"+
    "INSERT INTO data VALUES ('Shemp', 1895);"+
    "COMMIT;")

with con.execute("SELECT * from data") as cur:
    for row in cur:
        print("stooge:", row)
        
con.close()

print("usqlite mem - current:", usqlite.mem_current(), "peak:", usqlite.mem_peak())

the device freezes. I tried to disable the mem_status feature. I'm not sure how to debug this, but I noticed strange issue (at least for me). If I upload the generated uf2 using picotool, then connect to sqlite db from repl, disconnect, and then when I verify the uf2 with the device flash (using picotool verify) it shows that the images are not the same (ERROR: The device contents did not match the file).

What could be the cause? What information do you need from me? Thanks a lot.

Micropython 1.21 windows port: Compile error

Good day

Are there any plans to make usqlite compatible with micropython 1.21? I get a compile error in usqlite_cursor.c in function:

STATIC mp_obj_t row_tuple(usqlite_cursor_t *cursor) {
int columns = sqlite3_data_count(cursor->stmt);

mp_obj_tuple_t *o = m_new_obj_var(mp_obj_tuple_t, mp_obj_t, columns);
o->base.type = &mp_type_tuple;
o->len = columns;

for (int i = 0; i < columns; i++)
{
    o->items[i] = usqlite_column_value(cursor->stmt, i);
}

return MP_OBJ_FROM_PTR(o);

}

syntax error: ')' in line:
mp_obj_tuple_t *o = m_new_obj_var(mp_obj_tuple_t, mp_obj_t, columns);

Regards

Native code MPY?

Micropython supports native code in mpy files. This means that, theoretically, you could build this project in such a way that you do not need to build and use a new micropython firmware image... You would just download a pre-built usqlite.mpy file for your microcontroller architecture, copy it over, and away you go.

This would be a super useful option, especially for those who are hesitant to try building their own firmware.

Compilation on Ubuntu 20.04

Un grand merci !!! for this package ...
We introduce python, tcp, sql but also recurcivité, graph, conquer and divide, dynamic programmic for the new curriculum of informatic for the grade 11 and 12
So, use ESP32 with micropython and sqlite, it's amazing for us !!!!

Three day after, i just goal to compil a firmware with micropython and usqlite ....

The big purpose is :

  • use gcc8 and not gcc9
  • python 3.8 and not python 3.10
  • micropython 1.18 and not mycropython 1.19
    Some changes in new upgrade make impossible the compilation of usqlite

More information (in french) on my website : https://chinginfo.fr/dossier-esp32/?p=c

A big thank you for the porting of sqlite to micropython which will make the field of possibilities immense in our teaching

Cannot create table with UNIQUE or PRIMARY KEY

The following SQL

CREATE TABLE IF NOT EXISTS login(
  key TEXT NOT NULL PRIMARY KEY,
  name TEXT
);

Gives the error:

usqlite_Error: malformed database schema (sqlite_autoindex_login_1) - orphan index

Same happens if I try to set a column as UNIQUE.

Attempt to port on MicroPython 1.19 failed

I am using ESP32-S3 and ESP-IDF4.4.2, but there was an error during compilation:
#define TYPE_HAS_ITERNEXT(type) (type->flags & (MP_TYPE_FLAG_ITER_IS_ITERNEXT | MP_TYPE_FLAG_ITER_IS_CUSTOM | MP_TYPE_FLAG_ITER_IS_STREAM))
I think it should be caused by an incompatible version of MicroPython. May I ask which version of MicroPython you are using?

Or, how should I modify it for version 1.19?

Compil ESP32

Hello, I started compiling firmware again for ESP32 (generic, c3, s3) ... I tried again to include your usqlite module and I get the following errors (see attached file)

I saw that in your "micropython.cmake", you had put a conditional for compilation under ESP32 ... I took the liberty of "short-circuiting" the conditional to make sure the command would run with all my compilations, but it didn't change anything

I'll have some time in March and April to try things out if you like ... Unfortunately my knowledge of C and Python is too limited (as well as esp-idf) to hope to solve this problem myself.

I compile my files with the latest specifications for micropython :
ESP-IDF: 5.0
Micropython : 1.22
(and python 3.10)

Sincerely
Thomas castanet
erreur.txt
micropython.cmake.txt

Compil for ESP32

Hello, I just try the new version of uSqlite for micropython 1.196 ... No problems with the ports "unix" but it fails with the port "ESP32" ...

/sauvExt/esp32-1.19-4.4/modules/usqlite/sqlite3.c: In function 'sqlite3RunParser':
/sauvExt/esp32-1.19-4.4/modules/usqlite/sqlite3.c:171920:61: error: 'startedWithOom' undeclared (first use in this function); did you mean 'searchWith'?
     assert( db->mallocFailed==0 || pParse->rc!=SQLITE_OK || startedWithOom );

It's seems to be a problem of NDEBUG et SQLITE_DEBUG but i'm not able to correct it ...
Thanks for your work
Thomas

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.