SDL, SQLite3, and Emscripten

I noticed that SQLite3 is built into Emscripten as a port, and I was curious if I can use it to share/edit the “Top 100 Players” list in my game between all players. I haven’t used SQLite before, and I’m worried this might be a waste of time, every tutorial I have found only shows SQLite linking to local disk-based database files.
More than one of the tutorials that I found promise to show linking to a URL webhosted DB, but they did not deliver which is very frustrating. I have found a couple free DB hosting websites, and signed up for one, but now how do I access that database?

  1. Does anyone know of a good tutorial that actually shows linking to an externally hosted (URL) database?
  2. Can SQLite3 link to an external web-hosted database at all.
  3. Can/Should I download the DB file using SDL_net in an Emscripten build?

Edit: For my question about SDL_net; on further thought, I can’t just download the database because I wouldn’t be able to update the source with new player’s scores. I would need a way to send updates to the web hosted database itself, which is what I need SQLite to do in the first place.

I’m going deeper, I’ll post back with results.
Thank you for any help.

So the short answer is no, not possible. Local file access only. Here’s the source for that answer.
qt - Access sqlite from a remote server - Stack Overflow

So that was a little disappointing, but at least I didn’t spend too much time on the topic.

There must be some way of fetching and sharing top scores from an online Emscripten-compiled game. Does anyone have a process that they’re able to share?
… Or is Emscripten sand-boxed that completely?

Has anyone looked into the “fetch API” of emscripten → Fetch API — Emscripten 3.1.55-git (dev) documentation

It would be an emscripten specific solution, but I think I could write an abstraction class around SDL_net to maintain parity between g++ and emcc builds.

Edit:

  • The Fetch API does have fields for username and password, so it should be able to log in to remote host of some sort. I am too much of a novice on the web side to get a URL based web database. I just have to accept that for today and move on. I think my best bet would be to set up my own server, which is just not in the budget.

  • However, the fetch API does seem to offer a kind of local database permanence along with its other features, so it would be a way to implement save files in an emscripten build. This is actually something else that I was having issues with. That’s where I will set my focus for now.

… And that’s a fail as well. It’s very possible that I’m just not including the correct flags, or that I’m not using the API correctly, but the Fetch API is just giving me errors in the “Java Console” about stack overflow in the cookie. I didn’t even know that was possible. (ctrl-shift-j opens the Java console).

Frustration levels are now exceeding capacity on this topic.
I’ve joined the emscripten discord to try and get more info but so far it’s also a bit quiet on the topic.

All right, some glimmer of hope for persistent data. The Flare-engine has an emscripten build on itch.io that does persistent saves.
I’m off project for the rest of the night, but that’s where I’ll pick back up tomorrow.

OK, here’s a response that I got on Emscripten’s discord;

-flohofwoe wrote
I’m using indexedDb directly via embedded Javascript code here to save and load emulator snapshots (a few hundred KBytes to a few MBytes in size). Here’s all the JS and C code needed for that:

https://github.com/floooh/chips-test/blob/75d6867797f08f3c791681841f53dbe91790b766/examples/common/fs.c#L426-L564