Skip to content

Add dbhash and sqldiff utilities as JS APIs for working with SQLite #57637

Closed
@TheOneTheOnlyJJ

Description

@TheOneTheOnlyJJ

What is the problem this feature will solve?

With SQLite now shipped in Node, as it begins being used in more and more projects, friction points are being discovered.

As pointed to in this issue comment, some features of SQLite require external C/C++ implementations or utility programs to be used.

While not advocating for bloating Node with these programs, I believe a select subset of them can be adopted and integrated directly in Node.

I propose for discussion 2 of them:

  1. dbhash
  • Documentation
  • Code (C) is publicly available here.
  • Why? It allows creating a SHA1 hash based exclusively on the schemas and data contained in the database, excluding any other information. Use cases include quick & efficient data tampering detection, both locally and over the network.
  1. sqldiff

What is the feature you are proposing to solve the problem?

While I am not experienced enough in C/C++ to work on this, or even acknowledge if it is possible to be done efficiently, I propose investigating the possibility of having Node "wrap" these utility programs and expose them as JS APIs (maybe even in CLI?).
The 2 programs would require separate strategies, as dbhash outputs a SHA1 hash (or errors), and sqldiff creates a file (among other things and outputs, errors, etc.).
If the output could be reliably directed towards a Node processing layer (to filter out error messages meant for stderr, format the data, disallow anything reaching stdout, etc.) maybe this could be technically feasible with minimal to no changes to the original scripts, but I cannot approximate the amount of effort required to achieve this level of integration.

What alternatives have you considered?

I have not found any other way to easily get the hash of a database's contents. Having an API function/method available with a C implementation would ensure the best efficiency.
Installing the utilities as standalone programs creates setup friction and misses a convenient JS API for using them.

Metadata

Metadata

Assignees

No one assigned

    Labels

    feature requestIssues that request new features to be added to Node.js.sqliteIssues and PRs related to the SQLite subsystem.

    Type

    No type

    Projects

    Status

    Awaiting Triage

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions