Database on SDCard?

10 Mar 2011


For an Project I need a database directly on the mbed (SDCard). My first thought was that I try it with SQLite but I didn't find anything in the forum and cookbook over sqlite.

Has anyone experience with SQLite and Mbed or has anyone a other solution for my problem?

tia djonny

10 Mar 2011

Dear Klaus, this sounds nice. have you tried a compilation? My first problem was to upload the big c-file. I didn't solved this issue. br

10 Mar 2011

i used a delimited text create a table in memory

fields are separated by + and records by =

1+pulu+dog+13=2+mimi+cat+10=3+mik+bird+5 translates to

1 pulu dog 13

2 mimi cat 10

3 mik bird 5

you would need a three level pointer to represent it in memory though

11 Mar 2011

or you need a 4-dimensional array. Br

11 Mar 2011

Thanks for your answers @Thomas sorry I didn't have anything now

@Herson this is nice but I think I cant use this because in my Project. In the Project I must store a 2D Array with a size of 200x200 into a Database and I must compare one 2D Array with all other (I think 150 Arrays) in Database. So I think a txt file is not the right way for this.

Did you have any other Ideas how I can store this?

tia klaus

11 Mar 2011

200x200 array is quite big. assuming you are storing 32bit floats, that alone already occupies 40000*(4bytes) or 160000 bytes or 160 KByte. The mbed has a usable RAM of 32KB

Even if you use 8bit integers for the array, that still translate to 40KB, more than what the mbed can handle (just for loading a single array in memory)

11 Mar 2011

Further to what Herson said, I think you'l find SQLlite will try to use RAM buffers for executing the actual SQL queries only "swapping" when needed. Like most SQL engines they need a lot of RAM only updating disk files on actual updates (and in some cases even then the updates can be delayed). Given the SDcard is connected by SPI and usually moves byte blocks of 512bytes at a time I think you'll find with those data sizes the Mbed isn't going to cut it for you (unless you have oddles of time and "real time" isn't an issue). Sounds like you need more domestic power on the post processing/query side of things (like a PC or a Linux box)

One thing Herson didn't metion, the "150 or so" arrays that the compare is going to run against. That's Herson's figures multipled by another 150.

20 May 2011

I found a lot of information on implementing SQLite on SD Cards by Google searching "sqlite android" and "sqlite sd card".

29 Jan 2014

Does anybody knows MBed API to SQLite access ? Tks

30 Jan 2014

If you have to do this on an mbed and don't need the future flexibility of a generalized RDMS, why not do something like this:

  1. Store all the "2D Arrays" on the SD card.
  2. Open the source and comparator files
  3. Set boolean variable equal=1
  4. . Repeat for each row:
    1. Load a row from the source file into memory
    2. Load a row from the comparator file into memory
    3. Check the rows for equivalence
      1. If equivalent: continue
      2. If not equivalent, set equal=0 break
  5. If equal=1, you found a match, else repeat for next comparator file

So you don't really need a DB.

And in the above, you don't need to load a whole row. You could do this using only two tiny buffers if you really want. Or you can use giant buffers.

Even if you could get something like sqlite to work, it's unlikely to be any quicker than this since it won't be able to load everything into RAM, and it will basically be doing the same thing.