Hosting SQLite Databases on GitHub Pages

#12 · 🔥 563 · 💬 74 · 2 years ago · phiresky.netlify.app · isnotchicago · 📷
If you want to use a database, you either need to write a backend or download the whole dataset into the browser. So how do you use a database on a static file hoster? Firstly, SQLite is compiled to WebAssembly. Js only allows you to create and read from databases that are fully in memory though - so I implemented a virtual file system that fetches chunks of the database with HTTP Range requests when SQLite tries to read from the filesystem: sql. Thankfully, SQLite already organizes its database in "Pages" with a user-defined page size. If the index was ordered country code, indicator code, ..., then we would be able to quickly get all indicators for a single country, but not all country values of a single indicator. We can also make use of the SQLite FTS module so we can do a full-text search on the more text-heavy information in the database - in this case there are over 1000 human development indicators in the database with longer descriptions. Since we're already running a database in our browser, why not use our browser as a database using a virtual table called dom?
Hosting SQLite Databases on GitHub Pages



Send Feedback | WebAssembly Version (beta)