GithubHelp home page GithubHelp logo

webreflection / sqlite-worker Goto Github PK

View Code? Open in Web Editor NEW
173.0 4.0 4.0 2.02 MB

A simple, and persistent, SQLite database for Web and Workers.

Home Page: https://webreflection.medium.com/a-persistent-sqlite-for-the-web-90083827d1f8

License: ISC License

JavaScript 77.27% HTML 22.73%
sqlite3 worker service-worker persistent-storage

sqlite-worker's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

sqlite-worker's Issues

Custom DB functions?

Great project! I do not see a discussions tab so I will ask the question here.

In SQL-JS I use custom database functions, but I do not see a way to add these without building a custom package, am I missing something? Is there a way to interact directly with the sqlitedb instance?

Appreciate the feedback.

Resolve both `dir` and `library` options by default.

Currently, there is a fancy dance to make sql.js usable as both ESM and CommonJS, but this doesn't easily scale:

  • I don't control https://sql.js.org/dist files, so the .js export might differ from its counter .wasm version provided online
  • there are current issues in loading the non debugging version of sql.js, and this might penalize both performance and overall size
  • changing the worker library option my result into importing the library twice

What to do

  • load sql.js a part, instead of bundling within this module
  • resolve automatically both dir and library options
  • instrument the module to be able to load sql.js properly (ugly dance with CommonJS)

Absurd-Sql

It appears indexeddb is being written to all at once here. The Absurd-Sql, based on SQL-JS, project also uses it here, possibly there are some performance gains since it writes in blocks opposed to all at once.

Any examples using TypeORM?

They support SQL.js but would be great to see how to properly setup connection with your persistence layer.

OOM

Hi,

I am load testing and have noticed that the following happens when a row containing a single 1.3MB blob is written:

RuntimeError: memory access out of bounds
RuntimeError: table index is out of bounds
    at sql-wasm.wasm:0x36f48
    at sql-wasm.wasm:0x4259e
    at sql-wasm.wasm:0xb8643
    at za (sql-wasm.wasm:0xfa419)
    at e._sqlite3_close_v2 (VM26073 sql-wasm.js:2791)
    at c.export (VM26073 sql-wasm.js:420)
    at index.js:103
    at new Promise (<anonymous>)
    at index.js:102

This is possible on other sqlite3 implementations so I wonder if there is anything that can be done to make it work here as well

Many thanks

Edit: I originally posted 8.4MB but then found it happens also with as little as 1.3MB. I know it doesn't happen with 1MB, somewhere between 1MB and 1.3MB it hits a limit. This was tested on Chrome (Opera)

Failed to execute 'transaction' on 'IDBDatabase'

Occasionally, the following error occurs:

Failed to execute 'transaction' on 'IDBDatabase': A version change transaction is running.

Reproduce

  • clear the whole data
  • hard refresh

Expected

The iDB should never throw errors in general, but regardless it's opened and awaited, such error exists.

Problem injecting into query

Hi,

For some reason, the following throws an error:

let table = 'todos';
await all`SELECT * FROM ${table} `

It seems strings can't be injected into backtick quotes when querying, but they do work when executing. Am I doing something wrong?

Thanks

Testing Plugin

Hello,

I am testing your plugin and find this to be an awesome idea. I have a question in regards of the update option; what buffer do I use? The one created in indexeddb and how? Or one created somewhere else in memory/server? Could you please elaborate a bit more on this concept? Probably with an example of its use.

import {init} from '//unpkg.com/sqlite-worker';
init({name: 'my-db', update(uInt8Array) {
// store the latest uInt8Array somewhere
}});

My understanding is when the above code is run, it will grab same buffer used so I can continue doing crud operations on it. Am I right? I tried just like that but it does not seem to be doing anything at all.

Thank You.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.