I'm struggling to see the use case for minipg itself. For embedded or in-process postgres there's pglite as mentioned in comments. For dev/test parity there's embedded-postgres (go, java, node, python), which downloads native binaries and gives you a throwaway postgres with no docker. These by themselves cover what most people would want from "sqlite-style postgres," without the hypervisor layer or significant slow down.
Is minipg intended to become a real tool, or is it mainly a showcase for h9, with Postgres as the hard case that proves it works?
> So when you find self-hostable open source software you'd like to run on your own computer, it can be daunting when it says it requires Postgres. Now you're responsible for setting up a database and getting it ready for the software to use.
> Sure, you can run Postgres in Docker, and plenty of projects recommend it. But now you have two dependencies. If you don't already have Docker, you have to install it, which can mean a VM and a daemon on your machine. Then you have to run Postgres in it and make sure it's running whenever you use the software. That's a lot just to try something you don't know you want yet.
> Wouldn't it be great to have the SQLite experience, but with Postgres?
> That's miniPG . It isn't Postgres as a library. There's already a WASM project for that, reasonably called PGlite. miniPG is closer to the SQLite CLI[dead]
For unit tests I've found that I don't need PGLite or other tools, only podman and official images.
Regular postgres starts in 800 milliseconds, TimeScale DB in 1 second.
I have setup where first unit test that starts podman container and after finish it ends it all. On each test I create new database (or search path), time it takes to create db is in milliseconds.
Trick is to use `--image-volume tmpfs` when starting the container. I have my pg test server as Rust in here: https://github.com/Ciantic/app-frame/blob/main/crates/pgtest...
That said, PGlite is great and would have been ideal for the motivating problem, but as my blog post mentions (eventually), it only runs in single connection mode. For better or worse, applications will sometimes perform another query while in another transaction, causing deadlock with PGlite. It's fine if you can avoid that in your app, but makes it not work as a general drop-in replacement for existing apps.
The way I'd rather it be looked at, though, is just as a more convenient, "friendly" way to work with Postgres on the CLI. So maybe it's not for Postgres experts.
pglite is great for browser / testing emulation for PG. MySQL in browser does not have an equally good story. Closest is https://github.com/ephpm/litewire , but it isnt really MySQL fully.
Can't recommend it but I experimented myself with lite4mariadb and hit a few rough edges, e.g. transactions aren't isolated when the callback is async, memory use is insane. Issues are also disabled on the repo (it's a github fork), so there's nowhere to report bugs.
General issue of both is them being single-connection and being less battle tested.
If translation is acceptable, wordpress playground's sqlite driver (sqlite-database-integration) parses mysql into an ast which is based on my experience is the most proven approach in browser today.
Would be genuinely excited if mysql in WASM gets more attention.
[deleted]
Not very nice, yeah, I’d put that behind a “play” button of sorts.
[dead]
[dead]
[dead]
[dead]
[dead]
[dead]
[dead]
[dead]
[dead]
[dead]
[dead]
So, does this work well on Node.js? If it does I'm willing to make the jump from SQLite to this.
I still don't use postgres for my small projects, because sqlite gets you so far, so fast. You can just apt install postgres, but then you have all the aux questions:
When do you upgrade?
How is authentication handled?
How are we doing backups?
How do I deploy in production?
How do I restore from a backup?
With sqlite, these are either not as relevant or they have trivial answers. With postgres, each is another project/process to track.But of course, the way you frame your question sides-steps these challenges, and instead focuses on how to install the software, which was never the challenge being tackled.
So upgrade when you're working in your stack and upgrading things. Auth using Unix socket as per defaults Backup by backing up your whole server
Is any of this quite sufficient for at scale? Often not, I agree. But that wasn't the context of the question.
I think you would be better off with either https://github.com/electric-sql/pglite or https://github.com/f0rr0/oliphaunt
They actually run as a library, like sqlite does, with no separate process
If one needs an ACID database, he would also like programs to perform CRUD operations upon it, which requires a stable ABI. I can't see why one would want a CLI relational database. On the other hand, embedded OLAP databases such as DuckDB are mostly CLI-first and lib-second.
I am not a person who runs Mysql/mariadb-lite but I got curious by this and so I just ended up building the thing out of curiosity because why not: https://github.com/SerJaimeLannister/minimariadb-lite (Some more details[0])
Running it on web: https://serjaimelannister.github.io/minimariadb-lite/
Have a nice day!
[0]: Please note that it was a test on GLM 5.4 as I just wanted to try it and left it running for a day (I have an older account so it just has 5 hour resets and no weekly limits and just let it rip on the problem), some final finishes were done by GPT sol 6.2 (low)
Happy to hear things are getting smoother with Node.js SQLite, but then I have the other problem that Vercel-PKG support stopped at a specific Node.js level, so I wouldn't be able to use the native Node.js SQLite anyway I assume .
Now lately I discovered that there is an open-source fork of Vercel-PKG which supports later Node.js versions: npmjs.com/package/@yao-pkg/pkg?activeTab=readme&__cf_chl_tk=eDzgWvIL2OkIxMCGlCoLW6Mi2t2ciRkE6HMYKl46MnY-1795671127-1.0.1.1-fY.UrK80ucEtTwp1j_XEPi4eI5iwficmiVkl4qjE1HY .
Once I get my build-process ported to that or something similar I will certainly revisit the database question again for my project.
But then whether the Node.js native SQLite runs after compiling it into the Vercel-PKG exe lookalike I don't know (yet).
Edit: yeah, I also got confused about the “Vercel PKG EXE”, haha