No project description provided
Project description
jupyter_anywidget_pglite
Jupyter anywidget
and magic for working with pglite
(single use postgres wasm build).
Install from PyPi as: pip install jupyter_anywidget_pglite
Usage:
- import package and magic:
%load_ext jupyter_anywidget_pglite
from jupyter_anywidget_pglite import pglite_panel
pg = pglite_panel()
# w = pglite_panel("example panel title)`
# w = pglite_panel(None, "split-bottom")`
# Headless mode (no HTML UI, works in Jupyter Lab, Jupyter Notebook, VS Code w/ Jupyter notebook support)
#from jupyter_anywidget_pglite import pglite_headless
#pg = pglite_headless()
# Inline display — display HTML UI as initialising code cell outpu
# Display will be updated with consequent queries
#from jupyter_anywidget_pglite import pglite_inline
#pg = pglite_inline()
This should open a panel in the right-hand sidebar (split-right
) by default:
Running queries on the database using IPython cell block magic %%pglite WIDGET_VARIABLE
:
%%pglite_magic pg
CREATE TABLE IF NOT EXISTS test (
id serial primary key,
title varchar not null
);
#----
%%pglite_magic pg
INSERT INTO test (title) VALUES ('dummy');
#----
%%pglite_magic pg
SELECT * FROM test;
Currently, it seems as if you can only run one instrcution at a time / per magic cell.
Having made a query onto the database via a magic cell, we can retrieve the response:
pg.response
If pandas
is installed, we can get rows returned from a query response as a dataframe:
pg.df()
Close the panel (i.e. "disconnect" the database):
# Either close the panel directly or run:
w.close()
TO DO
- options to display outputs in the panel;
- how to handle lots on inputs?
- button to clear input history;
- button to reset database;
- explore possibility of a JuptyerLab extension to load
pglite
"centrally" and then connect to the same instance from any notebook.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for jupyter_anywidget_pglite-0.0.4.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | b539eb279c7966e2263b9c3f3ad9f98951fbd0e2cf322f819b7a33d079eb215a |
|
MD5 | a5f62ba097e06ef3519ebf4e3e57c913 |
|
BLAKE2b-256 | b50fd2d54241962b4587b93eb7b3b1e69f6579be64e8ee92e04578fe72e52584 |
Hashes for jupyter_anywidget_pglite-0.0.4-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e5bf6770a2cb8ea8d2e311b79f7d5987565f758bbb50107e51912ded86d4b3e4 |
|
MD5 | 95156b5c70c9cd5cb546113102549610 |
|
BLAKE2b-256 | 41ff76819e20092f28bd591137f66bcccf90702877dd4630feb8151207c6975a |