FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Load a database from the server · sql-js/sql.js Wiki · GitHub

/ sql.js Public

Load a database from the server

Ophir LOJKINE edited this page Jan 29, 2021 · 3 revisions

Here is how to load a database from your server using fetch, and open it with sql.js

const sqlPromise = initSqlJs({
  locateFile: file => `https://path/to/your/dist/folder/dist/${file}`
});
const dataPromise = fetch("/path/to/databse.sqlite").then(res => res.arrayBuffer());
const [SQL, buf] = await Promise.all([sqlPromise, dataPromise])
const db = new SQL.Database(new Uint8Array(buf));

Wiki pages Pages 7

Clone this wiki locally


Back | FazBrowse Home | New Git URL