We have a disconnected(no wireless network) application for a client using a local Web Sql database with ~100,000 records, ~10MB.
It contains barcode values, descriptions, etc. for items that may be scanned. The database changes frequently & the customer wants to be able push a replacement database to the device whenever
it is cradled and has a network connection. They have an existing device management application for pushing files from a management server to their handhelds.
We wanted the handheld RhoElements(RE) app to be in control of when the database file is replaced.
We observed that when the database was created by the web app it was named <WebSQLDBPATH>\file__0\0000000000000002.db, but were unsure if it would have the same name after an update of the RhoElements application to a newer version or after an update to our application if we added another database. Then we noticed the Databases.db file.
We came up with a potential solution but we wanted to get some feedback on whether there may be unforseen problems with it.
We developed a C++ console app built with sqlite.
It accepts 3 parameters
- database "name" used in a web sql open statement
- path to the Databases.db file as specified in the WebSQLDBPATH config entry for RhoElements
- path to the replacement database file delivered by the device management application
When the RE app is ready to pickup a database update it redirects to a page with no databases open and launches the C++ app passing the above mentioned parameters.
If the C++ app finds a replacement database file it opens the Databases.db file, gets the row for the named database from the Databases table and uses the information in that row
to construct the file path to the file used as the store for the named database. It then copies the replacement database file over top of the one used by WebSql.
It returns an exit status value back to the page indicating success or failure.
This seems to be working fine for our current tests but there are a few concerns we hope the RhoElements team could address:
1. Could the Databases.db file disappear in a future release of RE/webkit and invalidate this as a solution. Is there another(better) way to determine which physical file is associated with a WebSql database?
2. Currently when launching the C++ app from a web page with no database connections we have had no problems copying over the target database file.
Not knowing how the WebSql SQLite engine works, could that engine keep the file locked even if the database is not open by a web page, or is the database file always unlocked if the current page is not accessing it.
3. Did we miss something that could invalidate this solution?