Initialize the SQLite local database
To initialize an local SQLite database for a mobile app, check that the local database does not already exist; if it does not exist, retrieve a copy from the DB Sync server.
For a mobile app, the SQLite database file must be created in the application sandbox directory
using
os.Path.join(os.Path.pwd(),filename)
. For
example:DEFINE dbfile, dbsrce STRING
LET dbfile = os.Path.join(os.Path.pwd(),"library.dbf")
IF NOT os.Path.exists(dbfile) THEN
IF NOT _mbox_yn("Initial sync: proceed with full dbcopy?") THEN
EXIT PROGRAM 0
END IF
LET s = dbsync_app.get_database_copy(TRUE,dbfile)
IF s < 0 THEN
CALL _fatal_error("Could not get a db copy from dbsync server:\n"
|| SFMT(" %1 - %2", s, dbsync_err.get_error_message(s)) )
END IF
END IF
LET dbsrce = SFMT("%1+driver='dbmsqt'",dbfile)
CONNECT TO dbsrce