HTML5 and sqlite


#1

I found a previous thread suggesting that using a sharedobject allows saving of persistent LOCAL data with openfl. What I’d like to do is be able to open, read, and write to, an sqlite database.

All the packages I can find for sqlite seem to be based on sys, so can’t be targeted on HTML5. Once I have defined my sqlite database as a shared object, is there a way I can connect/read/write information to it that I’m missing?

Thanks in advance for any suggestions.


#2

On the web, there was a Web SQL proposal, which I believe has failed to be adopted by Mozilla, and (correct me someone if I am wrong?) IndexedDB may be the future here:

https://hacks.mozilla.org/2010/06/beyond-html5-database-apis-and-the-road-to-indexeddb/

Here’s a comparison of support:

https://caniuse.com/#search=db


#3

Thanks for this. From a practical point of view, how would you implement the ability to send queries to the database?

When I can access sys I use the following:

import sys.db.Sqlite;

public var localDB = Sqlite.open("localDB.db");
var titleQuery = localDB.request("SELECT title FROM game WHERE id ="+gameId+"");

I can’t see how I would implement something similar to this using a shared object.

var localDB = SharedObject.getLocal("localDB.db"); //loads it in, but I don't think this is the same as making a connection I can operate on.
var titleQuery = ..?

#4

Here’s an example I found:

Here’s a quick try.haxe

https://try.haxe.org/#b8EB9


#5

I can’t thank you enough for the try.haxe example. This seems like it will be perfect once I can get my head around it.

Thanks!