sqlx icon indicating copy to clipboard operation
sqlx copied to clipboard

feat: support `wasm` environments for postgresql

Open enmand opened this issue 1 year ago • 2 comments

This disables the home directory loading for WASM environments, as a filesystem to load files from is not available, as well as conditionally adding home on non WASM environments. With this, using sqlx-postgres is possible on wasm32-unknown-unknown targets.

enmand avatar Aug 27 '24 16:08 enmand

I think there's actually quite a bit more work involved getting wasm32-unknown-unknown working properly after digging in a bit more -- I'll investigate in this PR when I have some more free time available 🕵️

enmand avatar Aug 28 '24 02:08 enmand

Yeah, you also can't dial a TCP connection from normal Webassembly which unfortunately makes this a non-starter.

You'd have to compile for wasm32-wasi which is not a stable target IIRC and not supported in most WASM environments.

abonander avatar Aug 28 '24 03:08 abonander

Yeah -- my original plan was to use sqlite in a WASM environment (with e.g. in-memory DB only) for little toy project but the SQLite bindings didn't play nice with wasm32-unknown-unknown (the C bindings don't compile properly for that target).

Forgetting TCP is a non-starter, I started poking at the sqlx-postgres crate a bit and the rest is history.

I'll close this PR out now. Thank you!

enmand avatar Aug 28 '24 12:08 enmand