|
Post by hoho0482 on May 14, 2020 9:17:13 GMT
Hello,
Is it possible to access the embedded DB in anyway for ready only queries?
In my scenario, the app has an interface that allows the user to edit the working copy. I allow the user to revert specified records if they would rather get back to a factory default configuration. I do this with a reference table that mirrors the main table in structure and data but is not editable by the user. However the amount of content is now such that storing a mirror table makes the app larger than I would like. I figure I have that data already in the embedded DB if I can access it.
Target is iOS and Android.
Thanks,
Bob.
|
|
|
Post by echo17 on May 14, 2020 12:47:10 GMT
The sqlite library I am using requires a physical file to connect to. The embedded database is part of the Unity build, so it is not suitable for direct connections.
However, what you could do is temporarily copy the embedded database into your working directory (with a different name than your working database), you could then read data from the new copy into the working database. When you are finished, just delete the database you copied temporarily.
You can find how to extract the database in the SimpleSQLManager.cs script in the simpleSQL Library/SimpleSQL_Runtime project. Look at the Initialize method. The key part looks like:
File.WriteAllBytes(documentsPath, databaseFile.bytes);
Where documentsPath would be the the Application.persistentDataPath plus the name of the temporary file.
Ideally, you could set up a second SimpleSQLManager in your scene to connect to the temporary database. That way it would be a simple matter of reading from one and then writing to the other. Just be sure to Close() and Dispose() on the second db manager before delting the file.
|
|
|
Post by hoho0482 on May 14, 2020 13:30:32 GMT
As always, thank you for a quick and very helpful response. Hadn't thought of that approach.
Thanks,
Bob.
|
|