3 ms·
If you find this useful, you may also benefit from the fact that Python compiled to WASM (by Pyodide) also includes a working build of SQLite in the sqlite3 sta
by simonw 4y ago
If you find this useful, you may also benefit from the fact that Python compiled to WASM (by Pyodide) also includes a working build of SQLite in the sqlite3 standard library module.
You can try that out in a REPL here: https://pyodide.org/en/stable/console.html https://pyodide.org/en/stable/console.html
import sqlite3
db = sqlite3.connect(":memory:")
db.execute("select 4 * 5").fetchall()
Or in a full client-side WASM Jupyter notebook interface using https://jupyterlite.readthedocs.io/en/latest/try/lab https://jupyterlite.readthedocs.io/en/latest/try/lab
I also used Pyodide to get my Datasette SQLite Python web application running entirely in the browser at https://lite.datasette.io https://lite.datasette.io - more details on how that works here: https://simonwillison.net/2022/May/4/datasette-lite/ https://simonwillison.net/2022/May/4/datasette-lite/
- kungfufrog 4y agoHoly smokes, all of this is very cool! Nice work!
- g3 4y agoOr, if you want to go one level deeper, v86 has a complete Linux environment with both python and sqlite running locally: https://copy.sh/v86/?profile=archlinux&c=python%20-ic%20%27import%20sqlite3;%20db%20=%20sqlite3.connect(%22:memory:%22);%20print(db.execute(%22select%204%20*%205%22).fetchall())%27 https://copy.sh/v86/?profile=archlinux&c=python%20-ic%20%27i...
- kzrdude 4y agoThat's pretty trippy, I have my caps lock globally disabled (mapped to ctrl) in X config, but inside that v86 window, caps lock works. And it uses some hardcoded (US) keymap, too. I'm surprised, I didn't think browsers would receive those detailed keycodes.
- dorianmariefr 4y ago`event.key` returns the key with the mappings, e.g. "E" `event.keyCode` returns the physical key, e.g. "KeyE"