This is very cool. Having to always set up a server is one major downside of Postgres, with cumbersome updates being the second. This solves the first and has potential to help with the second. Is there a way to compile this as a native library? I imagine some of the work should be reusable.
Took the words out of my mouth, i can think of many use cases for this.
Imagine being able to go from 'embedded' to 'networked' without having to change any SQL or behavior, so cool.
I tried to use this when I was building a project about peer-to-peer database sharing in the browser using WebAssembly and WebRTC, but I found it a bit heavy so I used SQLite instead.
Hmm single user website run as HTML from some folder? I guess you could embed this from s3 for multiple users but probably this would be like running multiple engines from the same dir.
> Hmm single user website run as HTML from some folder? Why not just sqlite then?
I'm using this with a Bun project for my testing needs. I spin PGLite at the beginning, throw it all away at the end. It's not as nice as transactionally isolated testing (a la Ruby on Rails, or Elixir), but it's a fine replacement until I have time to replicate it.
While we originally built this for embedding into web apps, we have seen enormous growth in devtools and developer environments - both Google Firebase and Prisma have embedded PGlite into their CLIs to emulate their server products.
Hmm single user website run as HTML from some folder? I guess you could embed this from s3 for multiple users but probably this would be like running multiple engines from the same dir.
> Hmm single user website run as HTML from some folder? Why not just sqlite then?
Postgres features are much nicer, honestly if you are using any sort of orm none of this matters. by design they isolate you from many of the more interesting features of the database. And in general this is probably a good thing. But if you enjoy hand writing artisanal sql postgres is far more pleasant to use than sqlite, not that sqlite is bad, it is very good, just... thin after using pg.
It's cool that this is possible, is this just for fun or are there good use-cases for this?
It's now used by a huge number of developers for running local dev environments, and emulating server products (Google firebase and Prisma both embed it in their CLI). Unit testing postgres backed apps is also made significantly easer with it.
Using this for testing... it feels like a sweet spot between in-memory SQLite and spinning up a full Postgres instance. I'd been looking for this for a while and I'm pretty happy with the faster tests. And so far no blockers from its limitations.