database file serialisation

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?

What if there is no existing file?
create one?

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.

Just add a file then. Use SpecialFolder.documents with a new file name and it will be made for you by the DB class.

if by your last question you mean when you DID assign a file… .the database COMMIT action causes the data to be saved.

Thats the question, yes.

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.

it is create an SQLite database with no data… as in give it a name as opposed to being “in-memory”

Yup.
This appears to work in App.open:

[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]

Did you check the documentation?

https://documentation.xojo.com/api/deprecated/iossqlitedatabase.html#iossqlitedatabase-createdatabasefile