I can create an iOSSQLitedatabase in memory by not assigning a database file
If a sqlite file already exists, I can assign one to the database at startup.
What if there is no existing file?
Create a new database in memory?
Assign a non-existent folderitem?
What triggers the in-memory data to physically hit the folderitem file, so that in the event of a power outage, the data is safe?
Create a new database in memory? only if you don’t need the data later
Assign a non-existent folderitem? not sure what you are meaning here
What triggers the in-memory data to physically hit the folderitem file, so that in the event of a power outage, the data is safe? nothing… as in no event if that is what you are asking. I have apps where there is an in-memory database, where the user has normal file operations (save, save as, revert etc). for those I use the SQLite BACKUP command to copy the in-memory database to the physical file and vice-versa.
Presumably thats just ‘create a 0Kb file of the right name.’ rather than ‘create a small file which is in iOSSQLitedatabase format but doesnt have any data in it’
If the latter, I would have expected the iOSSQLitedatabase object to have some method that would create the ‘empty’ file.
Oddly, I dont have specific Commits in my code… usually it’s small updates inside small methods.
Update x where y Delete from A where B
Autocommit must be in play , since the sparse iOSSQLitedatabase documentation doesn’t seem to mention it.
[code]Dim dbFile As FolderItem
dbFile = SpecialFolder.Documents.Child(“mydata.sqlite”)
if dbfile.exists then
//====== for debugging… checking that a previous run actually saved some data
dim the_len as integer
the_len = dbFile.Length
//=========
TheDB.DatabaseFile =dbFile
exit sub //no need to create tables etc
else
dim t as TextOutputStream
t = textoutputstream.Create(dbFile,xojo.core.TextEncoding.ASCII)
t.Close
TheDB.DatabaseFile =dbFile // assign this 0Kb file to the database
end if
//initialise tables here
[/code]