1. Streamlit Communication
Good news for streamlit developers,
Some popular features available in Jupyter now are accessible in streamlit as well!
+ Save chart configuration
+ Use DuckDB as a computation engine for handling larger datasets
> Usage Note: If deploying on Streamlit, especially if it's publicly accessible, please adhere to the best practices for pygwalker on Streamlit. The demo code contains critical comments; ensure you understand them before integration.
demo code: https://github.com/Kanaries/pygwalker-in-streamlit/blob/main/pygwalker_comm_demo.py
online url: https://pygwalker-in-app-dngxb2r82ho2zqct244v7b.streamlit.app/
python
import pandas as pd
import streamlit.components.v1 as components
import streamlit as st
from pygwalker.api.streamlit import init_streamlit_comm, get_streamlit_html
st.set_page_config(
page_title="Use Pygwalker In Streamlit",
layout="wide"
)
st.title("Use Pygwalker In Streamlit(support communication)")
Initialize pygwalker communication
init_streamlit_comm()
When using `use_kernel_calc=True`, you should cache your pygwalker html, if you don't want your memory to explode
st.cache_resource
def get_pyg_html(df: pd.DataFrame) -> str:
When you need to publish your application, you need set `debug=False`,prevent other users to write your config file.
If you want to use feature of saving chart config, set `debug=True`
html = get_streamlit_html(df, spec="./gw0.json", use_kernel_calc=True, debug=False)
return html
st.cache_data
def get_df() -> pd.DataFrame:
return pd.read_csv("https://kanaries-app.s3.ap-northeast-1.amazonaws.com/public-datasets/bike_sharing_dc.csv")
df = get_df()
components.html(get_pyg_html(df), width=1300, height=1000, scrolling=True)
> Note: Ensure you review the demo code comments thoroughly before implementing the new Pygwalker in Streamlit.
2. Support external database as datasource & computation engine (Experimental)
Pygwalker now allows databases, like Snowflake, to be used as data sources and compute engines.
Example:
python
from pygwalker.data_parsers.database_parser import Connector
conn = Connector(
"snowflake://user_name:passwordaccount_identifier/database/schema",
"SELECT * FROM bike_share"
)
walker = pyg.walk(conn)
> Usage Note: It's currently not recommended to publish pygwalker applications using the Connector feature to the public network.
Feat
* feat: support communications on streamlit https://github.com/Kanaries/pygwalker/pull/228
* feat: support database connector https://github.com/Kanaries/pygwalker/pull/233
longxiaofei
**Full Changelog**: https://github.com/Kanaries/pygwalker/compare/0.3.6...0.3.7