pglite
pglite copied to clipboard
Rust Bindings
Are there any future plans to add Rust bindings for this? I can see this as an appealing alternative to bundling up Postgres as a sidecar for things like Tauri apps or using SQLite. Thanks
Are there any future plans to add Rust bindings for this? I can see this as an appealing alternative to bundling up Postgres as a sidecar for things like Tauri apps or using SQLite. Thanks
Maybe you could try using pglite directly within Tauri’s webview? I’m not sure if it will work, but it could be an interesting alternative to bundling Postgres as a sidecar.
That doesn't feel very secure imo, feels like it should sit on the rust side rather than in the webview, but appreciate the idea
Not keen on Rust, but maybe a valid approach would be to just run pglite inside rust with https://docs.wasmtime.dev/lang-rust.html like it was done for Go here https://github.com/electric-sql/pglite/issues/89
To go further than that POC you would need to pick a rust postgres wire protocol client crate though.
Besides wasm, can pglite also build to native code? Getting Rust to run regular wasm pglite would be awesome, but the downside is that it would still require a wasm runtime. Embedding a native build of pglite as a library in a Rust program would be very useful, if at all possible.
Right now what exists in Rust for "embedding" Postgres is pg_embed and postgresql-embedded. They can use native binaries from embedded-postgres-binaries (which is a trimmed down Postgres made for testing SQL queries in the Java ecosystem), or, in the case of postgresql-embedded, also from postgresql-binaries. pg_embed downloads the Postgres binary in the first run, and postgresql-embedded can also do that, but can package the Postgres binary inside its own binary to make distribution easier, extract it somewhere in the first run either way - Postgres still runs as a separate program. An upside for postgresql-embedded is that it supports Postgres extensions though.
Besides wasm, can pglite also build to native code?
Not yet, but we'd like it to. See the last part of this comment.
Super excited for libpglite to come!
Besides wasm, can pglite also build to native code?
Not yet, but we'd like it to. See the last part of this comment.
native rust would be huge for me- any idea on when this will be coming?
i think the correct way -now- would be to embded wasmtime. Only wasm sandboxing can offer safety that would be lost by compiling pglite as transpiled rust and/or unsafe C library.
Wasmtime embedding is quick, easy and ultra portable. Any other mean would probably be only possible as a long term project.
Why is wasmtime the way to go?
We want to extract the core changes to Postgres that we had to make and create a "libpglite" C lib that can be linked to from any language/platform.
Taken from: https://news.ycombinator.com/item?id=41225185
Wouldn't a libpglite be the most preferable way?
unsafe C library.
Wouldn't any issues be handled the rust side?
I'd love a working example to work off on if anyone has gotten wasmtime + pglite wasm file working.
I was able to get some basic stuff working for rust and wasmtime here: pglite-oxide
@f0rr0 super cool. what are current limitations?
@yujonglee you can run a unix/tcp socket and talk over wire protocol. or you can use the CMA channel and read/write command inputs/outputs. I also include the vector extension and pgdump. I am currently using it in my tauri desktop app so I guess I will eventually find out the limitations.
@f0rr0 Thanks for putting this together. Would be nice if the ReadMe could have a section for Tauri integration! 😄
Yes I’ll be adding that soon once I successfully integrate and run the whole thing
On Sat, 27 Sep 2025 at 2:15 PM, Paul @.***> wrote:
paulm17 left a comment (electric-sql/pglite#470) https://github.com/electric-sql/pglite/issues/470#issuecomment-3341411701
@f0rr0 https://github.com/f0rr0 Thanks for putting this together. Would be nice if the ReadMe could have a section for Tauri integration! 😄
— Reply to this email directly, view it on GitHub https://github.com/electric-sql/pglite/issues/470#issuecomment-3341411701, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACBNKC7FXWF4GVHACPZM5LD3UZFDFAVCNFSM6AAAAABTTLFAUGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZTGNBRGQYTCNZQGE . You are receiving this because you were mentioned.Message ID: @.***>
any updates on how to use with Tauri?