On Apr 23, 2015, at 3:51 PM, Simon Slavin <slavins at bigfraud.org> wrote: > > On 23 Apr 2015, at 9:29pm, Jeff M <jmat at mac.com> wrote: > >> Has there been any discussion about integrating sqlite with Apple's iCloud, >> either by using Apple's Core Data as the Virtual Machine's database engine >> (so the VM would operate on Core Data objects) or by otherwise modifying the >> existing backend? > > Apple has already tightly integrated SQLite with iCloud.
It's precisely that tight integration that I want to take advantage of, but without using Core Data directly and losing the ability to write queries using SQL. Core Data's use of SQLite is just coincidental and would not change. SQLite would be in the path twice: My app --> my special SQLite --> Core Data backend --> Core Data's normal SQLite and iCloud. Such a version of SQLite might be useful for people upgrading legacy apps for the cloud and who (like me) much prefer using the SQL language instead of Core Data objects. > You might instead be asking whether you could write an app which makes SQLite > calls to have data stores in iCloud. Yes, almost... > This could be done by writing a SQLite VFS which stored data in iCloud. I > don't know how well this would work, especially if more than one user was > trying to use a database. It might be difficult to implement because the > iCloud API doesn't map neatly onto the SQLite VFS API. I don't need to map SQLite to iCloud -- I only need to map SQLite to Core Data. Core Data then takes care of the iCloud issues. Also, I have no multi-user issues -- one app, one user, one database. > What would be easier is to use SQLite to store a database on your iCloud > Drive, as available in OS X 10.10 and above and some versions of Windows. > But there's nothing to do here: the drive is just a mounted volume like a > Flash drive or an AFP mount. Just use the right path in sqlite3_open(). And > experiment with concurrent multi-user use before you promise it, since iCloud > Drive locking is, I think, implemented with using SMB2. It the database file was small, iCloud Drive or Dropbox might work. But that fails with large files -- the user's device would be constantly syncing the entire database, even for small changes. This is why Core Data works -- it only syncs transactions. Jeff