B4J Question SQLite ExecNonQuery vs SD Card Writes

lip

Active Member
Licensed User
Longtime User
I have some issues with SD Cards in Pi's becoming corrupt (actually becoming ReadOnly) after a period of operation. It could be duff SD cards but I am also concerned about how many times I am writing to an SD card file.

I use a SQLite Database which typically does an INSERT, UPDATE or DELETE transaction every few seconds. If every one of these is a WRITE to the SD Card then I will fairly quickly reach 50,000 writes which will wear out the SD card memory.

I assume this is a single Write:-
.ExecNonQuery("INSERT INTO Table (Column1) VALUES 'Text')


Is this 1 or 100 Writes?
For i = 1 to `100
.ExecNonQuery("INSERT INTO Table (Column1) VALUES " & i)
Next

If the For Next loop is 100 Writes, then what if do it in a Transaction? Does it become a single Write?

Is there some other clever process going on so that the number of Writes is much less than this?
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
Please use [code]code here...[/code] tags when posting code.

If the For Next loop is 100 Writes, then what if do it in a Transaction? Does it become a single Write?
You should never call ExecNonQuery more than once without a transaction.
It will become a single write (+-) and it will be much faster.
 
Upvote 0
Top