- Notifications
You must be signed in to change notification settings - Fork1.1k
Load a database from the server
Ophir LOJKINE edited this pageJan 29, 2021 ·3 revisions
Here is how to load a database from your server using fetch, and open it with sql.js
constsqlPromise=initSqlJs({locateFile:file=>`https://path/to/your/dist/folder/dist/${file}`});constdataPromise=fetch("/path/to/databse.sqlite").then(res=>res.arrayBuffer());const[SQL,buf]=awaitPromise.all([sqlPromise,dataPromise])constdb=newSQL.Database(newUint8Array(buf));