Hi Anaqim,
It’s all to do with that problem I posted last week about data loss… with copying a master database from the resources directory to the documents directory for updating purposes, reading the existing database in the documents directory and storing it in memory, then writing it to the newly copied master database.
After the responses on the post I wanted to try and do the following:
Database structure example:
table_coins
table_coins will contain pre-populated data of all the coins.
1, 1999, Rare 1p
2, 2000 Rare 2p
table_userData
table_userData will contain user specific data that is manipulated through the app. E,g when a user types in that they have an amount of coins, this will insert a row into table_userData storing the information.
1, 3
2, 5
When the app is first opened, the master database is copied from resources to the documents directory and renamed to userData.
During an update:
userData.db will be in the documents directory.
Copy the master database from the resources directory to the documents directory (leaving name as master.db).
Open both databases.
Replace all of userData table_coins with master table_coins
In order to do that last step I wanted to do it via sql statements to avoid having to read each row from master, saving the results in memory then writing it to userData as that is basically how I do it at the moment with data loss occurring.
After reading everyones advice I was hoping to actually create a temp_table in userData, copy master.table_coins to userData.temp_table, check if it was successful, if it was then delete userData.table_coins and rename temp to table_coins.
I’ve been all over that page and the Internet for that matter lol… these 2 resources are very good but information seems sooo limited for what I am trying to do.
http://lua.sqlite.org/index.cgi/doc/tip/doc/lsqlite3.wiki
https://mroth.net/lua-sqlite3/documentation
Kind Regards,
Mike.