A javascript library to run SQLite on the web.

Overview

SQLite compiled to JavaScript

CI status npm CDNJS version

sql.js is a javascript SQL database. It allows you to create a relational database and query it entirely in the browser. You can try it in this online demo. It uses a virtual database file stored in memory, and thus doesn't persist the changes made to the database. However, it allows you to import any existing sqlite file, and to export the created database as a JavaScript typed array.

sql.js uses emscripten to compile SQLite to webassembly (or to javascript code for compatibility with older browsers). It includes contributed math and string extension functions.

sql.js can be used like any traditional JavaScript library. If you are building a native application in JavaScript (using Electron for instance), or are working in node.js, you will likely prefer to use a native binding of SQLite to JavaScript. A native binding will not only be faster because it will run native code, but it will also be able to work on database files directly instead of having to load the entire database in memory, avoiding out of memory errors and further improving performances.

SQLite is public domain, sql.js is MIT licensed.

API documentation

A full API documentation for all the available classes and methods is available. Is is generated from comments inside the source code, and is thus always up to date.

Usage

By default, sql.js uses wasm, and thus needs to load a .wasm file in addition to the javascript library. You can find this file in ./node_modules/sql.js/dist/sql-wasm.wasm after installing sql.js from npm, and instruct your bundler to add it to your static assets or load it from a CDN. Then use the locateFile property of the configuration object passed to initSqlJs to indicate where the file is. If you use an asset builder such as webpack, you can automate this. See this demo of how to integrate sql.js with webpack (and react).

const initSqlJs = require('sql.js');
// or if you are in a browser:
// var initSqlJs = window.initSqlJs;

const SQL = await initSqlJs({
  // Required to load the wasm binary asynchronously. Of course, you can host it wherever you want
  // You can omit locateFile completely when running in node
  locateFile: file => `https://sql.js.org/dist/${file}`
});

// Create a database
var db = new SQL.Database();
// NOTE: You can also use new SQL.Database(data) where
// data is an Uint8Array representing an SQLite database file

// Prepare an sql statement
var stmt = db.prepare("SELECT * FROM hello WHERE a=:aval AND b=:bval");

// Bind values to the parameters and fetch the results of the query
var result = stmt.getAsObject({':aval' : 1, ':bval' : 'world'});
console.log(result); // Will print {a:1, b:'world'}

// Bind other values
stmt.bind([0, 'hello']);
while (stmt.step()) console.log(stmt.get()); // Will print [0, 'hello']
// free the memory used by the statement
stmt.free();
// You can not use your statement anymore once it has been freed.
// But not freeing your statements causes memory leaks. You don't want that.

// Execute a single SQL string that contains multiple statements
sqlstr = "CREATE TABLE hello (a int, b char);";
sqlstr += "INSERT INTO hello VALUES (0, 'hello');"
sqlstr += "INSERT INTO hello VALUES (1, 'world');"
db.run(sqlstr); // Run the query without returning anything

var res = db.exec("SELECT * FROM hello");
/*
[
  {columns:['a','b'], values:[[0,'hello'],[1,'world']]}
]
*/

// You can also use JavaScript functions inside your SQL code
// Create the js function you need
function add(a, b) {return a+b;}
// Specifies the SQL function's name, the number of it's arguments, and the js function to use
db.create_function("add_js", add);
// Run a query in which the function is used
db.run("INSERT INTO hello VALUES (add_js(7, 3), add_js('Hello ', 'world'));"); // Inserts 10 and 'Hello world'

// Export the database to an Uint8Array containing the SQLite database file
var binaryArray = db.export();

Demo

There are a few examples available here. The most full-featured is the Sqlite Interpreter.

Examples

The test files provide up to date example of the use of the api.

Inside the browser

Example HTML file:

<meta charset="utf8" />
<html>
  <script src='/dist/sql-wasm.js'></script>
  <script>
    config = {
      locateFile: filename => `/dist/${filename}`
    }
    // The `initSqlJs` function is globally provided by all of the main dist files if loaded in the browser.
    // We must specify this locateFile function if we are loading a wasm file from anywhere other than the current html page's folder.
    initSqlJs(config).then(function(SQL){
      //Create the database
      var db = new SQL.Database();
      // Run a query without reading the results
      db.run("CREATE TABLE test (col1, col2);");
      // Insert two rows: (1,111) and (2,222)
      db.run("INSERT INTO test VALUES (?,?), (?,?)", [1,111,2,222]);

      // Prepare a statement
      var stmt = db.prepare("SELECT * FROM test WHERE col1 BETWEEN $start AND $end");
      stmt.getAsObject({$start:1, $end:1}); // {col1:1, col2:111}

      // Bind new values
      stmt.bind({$start:1, $end:2});
      while(stmt.step()) { //
        var row = stmt.getAsObject();
        console.log('Here is a row: ' + JSON.stringify(row));
      }
    });
  </script>
  <body>
    Output is in Javascript console
  </body>
</html>

Creating a database from a file chosen by the user

SQL.Database constructor takes an array of integer representing a database file as an optional parameter. The following code uses an HTML input as the source for loading a database:

dbFileElm.onchange = () => {
  var f = dbFileElm.files[0];
  var r = new FileReader();
  r.onload = function() {
    var Uints = new Uint8Array(r.result);
    db = new SQL.Database(Uints);
  }
  r.readAsArrayBuffer(f);
}

See : https://sql-js.github.io/sql.js/examples/GUI/gui.js

Loading a database from a server

using fetch
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));
using XMLHttpRequest
var xhr = new XMLHttpRequest();
// For example: https://github.com/lerocha/chinook-database/raw/master/ChinookDatabase/DataSources/Chinook_Sqlite.sqlite
xhr.open('GET', '/path/to/database.sqlite', true);
xhr.responseType = 'arraybuffer';

xhr.onload = e => {
  var uInt8Array = new Uint8Array(xhr.response);
  var db = new SQL.Database(uInt8Array);
  var contents = db.exec("SELECT * FROM my_table");
  // contents is now [{columns:['col1','col2',...], values:[[first row], [second row], ...]}]
};
xhr.send();

See: https://github.com/sql-js/sql.js/wiki/Load-a-database-from-the-server

Use from node.js

sql.js is hosted on npm. To install it, you can simply run npm install sql.js. Alternatively, you can simply download sql-wasm.js and sql-wasm.wasm, from the download link below.

read a database from the disk:

var fs = require('fs');
var initSqlJs = require('sql-wasm.js');
var filebuffer = fs.readFileSync('test.sqlite');

initSqlJs().then(function(SQL){
  // Load the db
  var db = new SQL.Database(filebuffer);
});

write a database to the disk

You need to convert the result of db.export to a buffer

var fs = require("fs");
// [...] (create the database)
var data = db.export();
var buffer = new Buffer(data);
fs.writeFileSync("filename.sqlite", buffer);

See : https://github.com/sql-js/sql.js/blob/master/test/test_node_file.js

Use as web worker

If you don't want to run CPU-intensive SQL queries in your main application thread, you can use the more limited WebWorker API.

You will need to download dist/worker.sql-wasm.js dist/worker.sql-wasm.wasm.

Example:

<script>
  var worker = new Worker("/dist/worker.sql-wasm.js");
  worker.onmessage = () => {
    console.log("Database opened");
    worker.onmessage = event => {
      console.log(event.data); // The result of the query
    };

    worker.postMessage({
      id: 2,
      action: "exec",
      sql: "SELECT age,name FROM test WHERE id=$id",
      params: { "$id": 1 }
    });
  };

  worker.onerror = e => console.log("Worker error: ", e);
  worker.postMessage({
    id:1,
    action:"open",
    buffer:buf, /*Optional. An ArrayBuffer representing an SQLite Database file*/
  });
</script>

See examples/GUI/gui.js for a full working example.

Flavors/versions Targets/Downloads

This library includes both WebAssembly and asm.js versions of Sqlite. (WebAssembly is the newer, preferred way to compile to JavaScript, and has superceded asm.js. It produces smaller, faster code.) Asm.js versions are included for compatibility.

Upgrading from 0.x to 1.x

Version 1.0 of sql.js must be loaded asynchronously, whereas asm.js was able to be loaded synchronously.

So in the past, you would:

<script src='js/sql.js'></script>
<script>
  var db = new SQL.Database();
  //...
</script>

or:

var SQL = require('sql.js');
var db = new SQL.Database();
//...

Version 1.x:

<script src='dist/sql-wasm.js'></script>
<script>
  initSqlJs({ locateFile: filename => `/dist/${filename}` }).then(function(SQL){
    var db = new SQL.Database();
    //...
  });
</script>

or:

var initSqlJs = require('sql-wasm.js');
initSqlJs().then(function(SQL){
  var db = new SQL.Database();
  //...
});

NOTHING is now a reserved word in SQLite, whereas previously it was not. This could cause errors like Error: near "nothing": syntax error

Downloading/Using:

Although asm.js files were distributed as a single Javascript file, WebAssembly libraries are most efficiently distributed as a pair of files, the .js loader and the .wasm file, like sql-wasm.js and sql-wasm.wasm. The .js file is responsible for loading the .wasm file. You can find these files on our release page

Versions of sql.js included in the distributed artifacts

You can always find the latest published artifacts on https://github.com/sql-js/sql.js/releases/latest.

For each release, you will find a file called sqljs.zip in the release assets. It will contain:

  • sql-wasm.js : The Web Assembly version of Sql.js. Minified and suitable for production. Use this. If you use this, you will need to include/ship sql-wasm.wasm as well.
  • sql-wasm-debug.js : The Web Assembly, Debug version of Sql.js. Larger, with assertions turned on. Useful for local development. You will need to include/ship sql-wasm-debug.wasm if you use this.
  • sql-asm.js : The older asm.js version of Sql.js. Slower and larger. Provided for compatibility reasons.
  • sql-asm-memory-growth.js : Asm.js doesn't allow for memory to grow by default, because it is slower and de-optimizes. If you are using sql-asm.js and you see this error (Cannot enlarge memory arrays), use this file.
  • sql-asm-debug.js : The Debug asm.js version of Sql.js. Use this for local development.
  • worker.* - Web Worker versions of the above libraries. More limited API. See examples/GUI/gui.js for a good example of this.

Compiling

In order to enable extensions like FTS5, change the CFLAGS in the Makefile and rebuild:

CFLAGS = \
        -O2 \
        -DSQLITE_OMIT_LOAD_EXTENSION \
        -DSQLITE_DISABLE_LFS \
        -DSQLITE_ENABLE_FTS3 \
        -DSQLITE_ENABLE_FTS3_PARENTHESIS \
+       -DSQLITE_ENABLE_FTS5 \
        -DSQLITE_ENABLE_JSON1 \
        -DSQLITE_THREADSAFE=0
Comments
  • Cannot enlarge memory arrays

    Cannot enlarge memory arrays

    Hi there

    I'm getting tonnes of:

    Cannot enlarge memory arrays. Either (1) compile with -s TOTAL_MEMORY=X with X higher than the current value 16777216, (2) compile with ALLOW_MEMORY_GROWTH which adjusts the size at runtime but prevents some optimizations, or (3) set Module.TOTAL_MEMORY before the program runs.

    Is there a way to increase the allowed memory? The memory keeps blowing out for me.
    Running in browser, client side

    opened by cheynewallace 33
  • Compile sql.js to wasm instead of

    Compile sql.js to wasm instead of "just" asm.js

    Emits WebAssembly and asm.js targets. Upgrades to Version 3.28.0 of Sqlite Upgrades to Version 1.38.30 of Emscripten

    I wanted to use the built-in modularize code, but I ran into some of the issues spelled out in https://github.com/kripken/emscripten/issues/5820, so I have continued the sql.js tradition of modularizing it manually via pre and post files. There is now a promise exported that you wait on, and this promise resolves with the SQL module. This way, SQL isn't usable until the WebAssembly or asm.js has been loaded.

    Since I made some more fundamental changes to how the module is loaded, and since this project now emits so many targets, I am not sure if it would be better to fork sql.js? sql.js is no longer drop-in compatible with previous versions due to the async loading. I have documented this here in README.md: https://github.com/kripken/sql.js/pull/255/files#diff-04c6e90faac2675aa89e2176d2eec7d8

    I also ran into a bug involving the creation of the sql-optimized file, so I restructured the Makefile a fair amount. It's not as DRY/fancy now, but it was easier to fix the issue. I have also made it easier to update the version of Sqlite used when compiling by borrowing heavily from https://github.com/mandel59/sqlite-wasm

    It's worth mentioning that the worker test running in the node environment does not work when loaded with a WebWorker simulator, so I have skipped that test for now.

    This PR cleans up other issues as well: Fixes #219 Fixes #173 Fixes #262
    Fixes #258 Fixes #251
    Fixes #232 Fixes #210 Fixes #115

    I look forward to hearing your thoughts.

    TODOs:

    • [x] Ensure that the mechanism for loading the module asynchronously works well in the browser
    • [x] Update the readme for browser and Node usage
    • [x] Add myself to AUTHORS
    • [x] Bump major version
    opened by Taytay 27
  • How to NOT block DOM UI?  async?

    How to NOT block DOM UI? async?

    I have very large static json data (150k count)

    When I initially create table, insert 150k , it block the browser UI, not responsive, until insert completed

    Ideally I am ok with long time it took for inserting, indexing, as long as it NOT block UI.

    I know if I move operation into web worker, it will not block main thread UI. But it complex other thing, not wanted.

    sql.js seem asynchronous already,see below code. but why, for large data, it still block DOM UI?????

      `
         
          initSqlJs(config).then(function(SQL){
    
              // async code here, should not block DOM UI, 
             // however, it did BLOCK UI, browser not responsive until insert finished.
    
                db.insert...
    
       }
    

    `

    opened by hoogw 22
  • remove `-DLONGDOUBLE_TYPE=double` from `Makefile`

    remove `-DLONGDOUBLE_TYPE=double` from `Makefile`

    in order to resolve the long double issue reported in #325

    How tested:

    • Verified that the test proposed in PR #336 succeeds on rebuild of dist/sql-asm.js and dist/sql-wasm.js
    • Verified that running SELECT 1.7976931348623157e+308 in examples/GUI web page with rebuild of dist/worker.sql-wasm.js works correctly

    Thanks to @AnyhowStep for raising issue #325 and pointing out the suspect -DLONGDOUBLE_TYPE=double flag in https://github.com/kripken/sql.js/issues/325#issuecomment-573239220.

    I suspect that this flag was needed in an old version of asm.js, does not seem to be needed in new emsdk version. Note that I have tested with emsdk version 1.39.4; looks like they published emsdk version 1.39.7 pretty recently.

    Follow-up steps if this proposal is accepted and merged:

    • [ ] update this repository with rebuild of all artifacts in dist (I think it would be ideal to rebuild with latest emsdk version, if possible)
    • [ ] review and hopefully merge the new test proposed in PR #336
    opened by brodybits 22
  • Update everything

    Update everything

    I updated old code and added new feature.

    • More recent version of SQLite (3.8.4)
    • Compiled to asm.js (should be faster, at least on firefox)
    • Changed API. Results now have the form [{'columns':[], values:[]}]
    • Improved GUI of the demo. It now has :
      • syntax highlighting
      • nice HTML tables to display results
      • ability to load and save sqlite database files

    If you want to merge only some changes, I can make several distinct pull requests.

    opened by lovasoa 22
  • Integrate sql.js with WebPack/React.js without react-app-rewired

    Integrate sql.js with WebPack/React.js without react-app-rewired

    I'm trying to integrate sql.js into my WebPack/React.js app but without using react-app-rewired.

    Instead, I am trying to configure my WebPack on its own. Added the following line:

    node: {
        fs: 'empty'
    }
    

    to base WebPack config after npm install sql.js webpack-copy-plugin and added the following line:

        new CopyPlugin({ patterns: [{ from: 'node_modules/sql.js/dist/sql-wasm.wasm', to: 'static/js/' }] })
    

    to the modules.

    However, I am getting the following error still:

    image

    How do I get around solving this?

    opened by iwangotamarjo 18
  • Export improvements

    Export improvements

    Based on #302 I’ve been trying to improve export, and this has lead me on a path™. Have you considered using one of these options?

    1. VACUUM INTO a temporary file that’s read, unlinked and returned
    2. Using sqlite’s Online Backup API to create a copy that’s returned
    3. Duplicating and returning the working memory via deserialize

    In this PR, I’m giving (1) a shot. I’m very interested to hear what you have to say. Ultimately, option (2) might be better suited for a generic export function since it doesn’t incur a VACUUM, and I will most likely give that a try as well.

    On a related note: Since the current filesystem is MEMFS, have you considered just using an in-memory database instead? Right now, sqlite believes it’s writing to a persistent filesystem, but MEMFS is backed by memory. Since everything’s happening in-memory anyway, why not use sqlite’s native memory-backed mechanics and drop the MEMFS indirection along the way?

    I have no experience with IDBFS (#397), and boy would I prefer if we had something like NativeIO.

    Some notes to self:

    • [ ] Add test for #159
    • [ ] Test using bound statements after export
    • [ ] Test using JS function after export
    opened by seidtgeist 17
  • Release latest version on NPM?

    Release latest version on NPM?

    It looks like SQL.js was improved to use the latest version of SQLite3 and emscripten recently, but the NPM package hasn't been updated since March 24th. Any chance you could publish the latest version so we could give it a go? Thanks!

    opened by Taytay 17
  • make sqlite v3.20.0

    make sqlite v3.20.0

    make

    Generate llvm bitcode

    /home/kirill/emsdk/emscripten/1.37.13/emcc -DSQLITE_OMIT_LOAD_EXTENSION -DSQLITE_DISABLE_LFS -DLONGDOUBLE_TYPE=double -DSQLITE_INT64_TYPE="long long int" -DSQLITE_THREADSAFE=0 -DSQLITE_ENABLE_FTS3 -DSQLITE_ENABLE_FTS3_PARENTHESIS c/sqlite3.c -o c/sqlite3.bc c/sqlite3.c:385:5: error: token is not a valid binary operator in a preprocessor subexpression #if SQLITE_INT64_TYPE ^~~~~~~~~~~~~~~~~ :8:32: note: expanded from here #define SQLITE_INT64_TYPE long long int ~~~~ ^ 1 error generated. ERROR:root:compiler frontend failed to generate LLVM bitcode, halting Makefile:42: ошибка выполнения рецепта для цели «c/sqlite3.bc» make: *** [c/sqlite3.bc] Ошибка 1

    opened by zirill 16
  • Error: Out of Memory in 1.5.0 when creating database

    Error: Out of Memory in 1.5.0 when creating database

    I tried to upgrade sql.js in one of my projects from 1.4.0 to 1.5.0. This caused the project to no longer work (no other dependencies upgraded at the same time), but fail with an Error: Out of memory failure, when trying to call new sqlite.Database().

    I've created a minimal reproducible example: https://codesandbox.io/s/sqljs-150-oom-ptd8l

    import initSqlJs from "sql.js";
    
    initSqlJs({
      locateFile: (file) => `https://sql.js.org/dist/${file}`
    }).then((sqlite) => {
      new sqlite.Database();
    });
    

    The new sqlite.Database() call will fail with an out of memory error.

    I can reproduce the behavior in Chromium and Firefox on my machine (Linux).

    opened by timroes 15
  • Move the project to a github organisation

    Move the project to a github organisation

    Hello @kripken , I am opening this issue to discuss moving this repository to a github organization. Currently, the repository is on your personal account, and I cannot access its settings. The first thing I would like to do when I get access to the settings is adding an NPM token to the repository so that I can setup continuous deployment of the sql.js npm module. What do you think ?

    opened by lovasoa 15
  • Add support for es module and browser-only environment

    Add support for es module and browser-only environment

    This PR addresses #284.

    I've tested this change using the current create-react-app along with this webpack config:

    configure: (webpackConfig) => {
      webpackConfig.resolve.extensions.push(".wasm");
      webpackConfig.experiments = {
        asyncWebAssembly: true,
        topLevelAwait: true,
      };
      webpackConfig.module.rules.forEach((rule) => {
        (rule.oneOf || []).forEach((oneOf) => {
          if (oneOf.type === "asset/resource") {
            oneOf.exclude.push(/\.wasm$/);
          }
        });
      });
      return webpackConfig;
    },
    
    opened by stephen 0
  • why e.stackAlloc null?

    why e.stackAlloc null?

    image

    sql-wasm.js?fdac:formatted:2941 Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'apply')
        at e.stackAlloc (sql-wasm.js?fdac:formatted:2941:50)
        at e.onRuntimeInitialized (sql-wasm.js?fdac:formatted:169:21)
        at a (sql-wasm.js?fdac:formatted:2981:27)
        at Zc (sql-wasm.js?fdac:formatted:3001:26)
        at Yc (sql-wasm.js?fdac:formatted:2958:19)
        at a (sql-wasm.js?fdac:formatted:2706:17)
        at b (sql-wasm.js?fdac:formatted:2709:17)
    
    
    opened by otary 0
  • There is no commit for transactions? (No way to DELETE rows / etc?)

    There is no commit for transactions? (No way to DELETE rows / etc?)

    Hi -- I'm attempting to DELETE a row in a simple query, however I can't db.commit(query); because it doesn't exist with sql.js seemingly? It takes the query just fine but obviously it's never committed for the changes.

    Any ideas / work arounds used by other people?

    Thanks

        initSqlJs().then(function (SQL) {
          const db = new SQL.Database(dbFile);
          const res = db.exec(query);
          const modified = db.getRowsModified(query);
          // db.commit(query); This doesn't exist...
    
          console.log(res); // shows a blank array []
          console.log(modified); // Shows the amount of "modified" rows
    
          resolve(res);
          db.close();
        });
    
    opened by webdevbrian 0
  • Electron package related bug when load wasm file

    Electron package related bug when load wasm file

    The original code filename = nodePath'normalize'; is buggy when using it used with electron package. fs.readFile will take this to a wrong path on electron packaged. For exmaple: I have a packaged file path "'file:///C:/**/resources/app/dist/demo.wasm", fs.readFile will throw a error like: "Error: ENOENT: no such file or directory, open 'C::\C:\resources\app\dist\demo.wasm"

    Actually it's a bug with emscripten, I have created a pull request for emscripten https://github.com/emscripten-core/emscripten/pull/18226)

    opened by justid 1
  • "Official" build of SQLite for WebAssembly

    You may already be aware, but SQLite 3.40.0 was just released this morning, and it adds a beta release of an official WebAssembly build.

    https://sqlite.org/wasm/doc/trunk/index.md Changelog: https://sqlite.org/releaselog/3_40_0.html

    Your library likely still has some value-added features over using SQLite directly, but it might allow you to simplify this library a little bit?

    opened by Daniel15 1
  • How do I INSERT an image as a BLOB INTO SQLite using SQL.js running from file:///?

    How do I INSERT an image as a BLOB INTO SQLite using SQL.js running from file:///?

    LOVASOA,

    First and foremost thank you very much for all your hardwork maintaining SQL.js.

    I just wanted to bring your attention to the stackoverflow question that I posted yesterday.

    I uploaded a .zip file with the contents of this file and the sql.js file I AM using to: https://fastupload.io/en/Stpx1gnfnmmieaT/file

    I entered a stackoverflow.com issue on October 1, 2022: https://stackoverflow.com/questions/73921879/how-do-i-insert-an-image-as-a-blob-into-sqlite-using-sql-js-running-from-file

    I entered this github.com issue on October 2, 2022: https://github.com/sql-js/sql.js/issues/531

    I found a relevant project input by LOVASOA, maintainer of SQL.js: https://github.com/lovasoa/bin2png

    Someone edited my "THANK YOU" message from the comment but please know I very much appreciate you and all of you out there who help us all on your time with your incredible expertise and HighLY INTELLECTUAL expertise.

    I've copied the stackoverflow message and code here for you:

    ================================================================== How do I INSERT an image as a BLOB INTO SQLite using SQL.js running from file:///?

    I AM using an older version of SQL.js, https://raw.githubusercontent.com/lovasoa/sql.js/master/js/sql.js , BeCAUSE I AM running from file:/// without a localhost server and the latest version requires downloading the WASM files from a server. IN THE STACKOVERFLOW.com RUN CODE SNIPPET SQL.js is throwing an "ReferenceError: SQL is not defined" exception. It works when the src is downloaded locally. I uploaded a .zip file with the contents of this file and the sql.js file I AM using to: https://fastupload.io/en/Stpx1gnfnmmieaT/file . I have a Base64 encoding/decoding solution working but cannot get a BLOB solution working.

    JAVASCRIPT FileReader to SQL.JS to INSERT IMAGE AS BLOB to SQLITE DATABASE TEST
    ================================================================== The code must run offline so I am using Javascript's FileReader object using an older version of sql.js so that no localhost server is required to download wasm files.
    fileReader.result directly but returns no such column: object ArrayBuffer error.
    fileReader.result with new Uint8Array to create a new SQL.Database but sql.js throws an 'abort' error.
    inputTypeFile.files[0] directly but returns no such column: object File error.
    inputTypeFile.files[0] with new Uint8Array to create a new SQL.Database but sql.js throws an 'abort' error.
    readAsArrayBuffer array buffer directly but returns no such column: object ArrayBuffer error.
    readAsArrayBuffer with new Uint8Array to create a new SQL.Database but sql.js throws an 'abort' error.
    readAsDataUrl using split to include only pertinent BASE64 information but Error: near "ÿØÿà": syntax error.
    

    Only solutions I can find are using Base64 or Base62 data URI encoding.

    THE SPIRIT OF TRUTH FLOWs here ...

    RespectfulLY,

    John Edgar Flaherty IV TRUTH "MAKE A WAY"

    opened by THE-SPIRIT-OF-TRUTH-FLOWs-here 0
Releases(v1.8.0)
Owner
SQL.JS
sql.js is a relational database for the web
SQL.JS
ORM for TypeScript and JavaScript (ES7, ES6, ES5). Supports MySQL, PostgreSQL, MariaDB, SQLite, MS SQL Server, Oracle, SAP Hana, WebSQL databases. Works in NodeJS, Browser, Ionic, Cordova and Electron platforms.

TypeORM is an ORM that can run in NodeJS, Browser, Cordova, PhoneGap, Ionic, React Native, NativeScript, Expo, and Electron platforms and can be used

null 30.1k Jan 3, 2023
Realm is a mobile database: an alternative to SQLite & key-value stores

Realm is a mobile database that runs directly inside phones, tablets or wearables. This project hosts the JavaScript versions of Realm. Currently we s

Realm 5.1k Jan 3, 2023
TypeScript ORM for Node.js based on Data Mapper, Unit of Work and Identity Map patterns. Supports MongoDB, MySQL, MariaDB, PostgreSQL and SQLite databases.

TypeScript ORM for Node.js based on Data Mapper, Unit of Work and Identity Map patterns. Supports MongoDB, MySQL, MariaDB, PostgreSQL and SQLite datab

MikroORM 5.4k Dec 31, 2022
Next-generation ORM for Node.js & TypeScript | PostgreSQL, MySQL, MariaDB, SQL Server & SQLite

Prisma Quickstart • Website • Docs • Examples • Blog • Slack • Twitter • Prisma 1 What is Prisma? Prisma is a next-generation ORM that consists of the

Prisma 28k Jan 2, 2023
WebAssembly SQLite with experimental support for browser storage extensions

wa-sqlite This is a WebAssembly build of SQLite with experimental support for writing SQLite virtual filesystems and virtual table modules completely

Roy Hashimoto 260 Jan 1, 2023
Ecommerce-backend-nestjs - Ecommerce app with Nestjs + Prisma ORM + GraphQL + SQLite

ECOMMERCE BACKEND NESTJS APP Nestjs + Prisma ORM + GraphQL + SQLite USER Create Account Login Product Create Product Get Products Get Product Search P

Rui Paulo Calei 5 Apr 6, 2022
Same as sqlite-tag but without the native sqlite3 module dependency

sqlite-tag-spawned Social Media Photo by Tomas Kirvėla on Unsplash The same sqlite-tag ease but without the native sqlite3 dependency, aiming to repla

Andrea Giammarchi 17 Nov 20, 2022
A Node.js ORM for MySQL, SQLite, PostgreSQL, MongoDB, GitHub and serverless service like Deta, InspireCloud, CloudBase, LeanCloud.

Dittorm A Node.js ORM for MySQL, SQLite, PostgreSQL, MongoDB, GitHub and serverless service like Deta, InspireCloud, CloudBase, LeanCloud. Installatio

Waline 21 Dec 25, 2022
A remote nodejs Cached sqlite Database Server, for you to have your perfect MAP Cache Saved and useable remotely.

A remote nodejs Cached sqlite Database Server, for you to have your perfect MAP Cache Saved and useable remotely. Easy Server and Client Creations, fast, stores the Cache before stopping and restores it again! it uses ENMAP

Tomato6966 6 Dec 18, 2022
Explore, create and deploy your SQLite databases right from your browser. Quick and easy, no installation required.

SQLighter (under development, alpha code) SQLighter is a database explorer born for SQLite that helps you design and deploy your application database

sqlighter 11 Sep 20, 2022
Run official FLAC tools `flac` and `metaflac` as WebAssembly, on browsers or Deno.

flac.wasm Run official FLAC tools flac and metaflac as WebAssembly, on browsers or Deno. Currently we have no plans on supporting Node.js. Try it onli

Pig Fang 15 Aug 21, 2022
Run SPARQL/SQL queries directly on Virtuoso database with connection pool support.

?? virtuoso-connector Package that allows you to create a direct connection to the Virtuoso database and run queries on it. Connection can be used to

Tomáš Dvořák 6 Nov 15, 2022
Avocano is a sample dropship/fake product website with Cloud Run, Cloud SQL and Cloud Build

Avocano - A Fake Product Website Avocano is a sample dropship/fake product website, combining: Firebase Hosting front end, written with Lit, Cloud Run

Google Cloud Platform 9 Dec 9, 2022
A transparent, in-memory, streaming write-on-update JavaScript database for Small Web applications that persists to a JavaScript transaction log.

JavaScript Database (JSDB) A zero-dependency, transparent, in-memory, streaming write-on-update JavaScript database for the Small Web that persists to

Small Technology Foundation 237 Nov 13, 2022
DolphinDB JavaScript API is a JavaScript library that encapsulates the ability to operate the DolphinDB database, such as: connecting to the database, executing scripts, calling functions, uploading variables, etc.

DolphinDB JavaScript API English | 中文 Overview DolphinDB JavaScript API is a JavaScript library that encapsulates the ability to operate the DolphinDB

DolphinDB 6 Dec 12, 2022
Lovefield is a relational database for web apps. Written in JavaScript, works cross-browser. Provides SQL-like APIs that are fast, safe, and easy to use.

Lovefield Lovefield is a relational database written in pure JavaScript. It provides SQL-like syntax and works cross-browser (currently supporting Chr

Google 6.8k Jan 3, 2023
A tiny javascript + Flash library that enables the creation and download of text files without server interaction.

Downloadify: Client Side File Creation Important! The swf has been compiled for online use only. Testing from the file path (i.e. file:// ) will not w

Doug Neiner 853 Nov 21, 2022
XML/HTML parser and processing library for JavaScript and TypeScript

[VIEW DOCUMENTATION] Robin is an XML parser and processing library that supports a sane version of HTML. It features a set of DOM utilities, including

null 15 Oct 5, 2022