While reading this thread, I realized that you could already access PGlite in Pyodide.
Pyodide is a Wasm port of CPython.
It can work with JavaScript objects through proxies.
Here is a demo.
I have run the code in current Node.js 18, Deno 1, and Bun 1.
import { PGlite } from "@electric-sql/pglite";
import { loadPyodide } from "pyodide";
globalThis.db = new PGlite();
let pyodide = await loadPyodide();
console.log(
await pyodide.runPythonAsync(`
import js
ret = await js.db.query("""
SELECT 'Hello, world!'
AS "greeting";
""")
ret.rows[0].greeting
`),
);
While reading this thread, I realized that you could already access PGlite in Pyodide. Pyodide is a Wasm port of CPython. It can work with JavaScript objects through proxies.
Here is a demo. I have run the code in current Node.js 18, Deno 1, and Bun 1.
It works on my machine: