Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
TheOneTheOnlyJJ opened this issue Mar 26, 2025 · 6 comments
Closed
Labels
feature request Issues that request new features to be added to Node.js. sqlite Issues and PRs related to the SQLite subsystem.

Comments

@TheOneTheOnlyJJ
Copy link

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.

@TheOneTheOnlyJJ TheOneTheOnlyJJ added the feature request Issues that request new features to be added to Node.js. label Mar 26, 2025
@github-project-automation github-project-automation bot moved this to Awaiting Triage in Node.js feature requests Mar 26, 2025
@cjihrig
Copy link
Contributor

cjihrig commented Mar 26, 2025

I am -1 to shipping additional SQLite utility binaries with Node since anyone can obtain these independently from Node.

@geeksilva97
Copy link
Contributor

For RBU, we have the possibility that is exposing RBU API

@TheOneTheOnlyJJ
Copy link
Author

For RBU, we have the possibility that is exposing RBU API

I'm not sure what you are referring to, could you please be more specific?

@TheOneTheOnlyJJ
Copy link
Author

TheOneTheOnlyJJ commented Mar 26, 2025

I am -1 to shipping additional SQLite utility binaries with Node since anyone can obtain these independently from Node.

Understandable. It is peculiar that such useful functionality lives in separate binaries. Could there be any other way to expose it in Node while avoiding including them?

For example, in my current project (Bachelor's thesis) I have good use cases for dbhash, but it is a hassle to integrate it as a separate dependency (also because the project is an Electron.js application). It would be very convenient to have a JS-level API that would achieve the same functionality one way or another.

@cjihrig
Copy link
Contributor

cjihrig commented Mar 26, 2025

Could there be any other way to expose it in Node while avoiding including them?

I don't think so. The fact that SQLite ships them separately says to me that they shouldn't be included at all. I also haven't heard of any other runtimes/libraries that include them (but I haven't checked either).

Since both of these things are CLIs, you could always interact with them via the child process API or something similar.

It's also important to remember that node:sqlite is not intended to be a dedicated SQLite development suite, and so not every SQLite tool should be included in Node.

@cjihrig cjihrig added the sqlite Issues and PRs related to the SQLite subsystem. label Mar 27, 2025
@cjihrig
Copy link
Contributor

cjihrig commented Apr 3, 2025

I'm going to close this since this isn't something we are realistically going to add.

@cjihrig cjihrig closed this as completed Apr 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request Issues that request new features to be added to Node.js. sqlite Issues and PRs related to the SQLite subsystem.
Projects
Archived in project
Development

No branches or pull requests

3 participants