CRUD interface for sqlalchemy using streamlit
Project description
streamlit_sql
Introduction
This package shows a CRUD frontend to a database using sqlalchemy in a streamlit app. With few lines of code, show the data as table and allow the user to read, filter, update, create and delete rows with many useful features.
Features
READ
- Display as a regular st.dataframe
- Add pagination, displaying only a set of rows each time
- Display the string representation of a ForeignKey column (Using str method), instead of its id number
- Select the columns to display to the user
- Add a column to show the rolling sum of a numeric column
FILTER
- Filter the data by some columns before presenting the table. It can use columns from relationship tables too.
- Let users filter the columns by selecting conditions in the sidebar
- Give possible candidates when filtering using existing values for the columns
- Let users select ForeignKey's values using the string representation of the foreign table, instead of its id number
CREATE / UPDATE / DELETE
- Users create new rows with a dialog opened by clicking the create button
- Users update rows with a dialog opened by clicking on desired row
- Text columns offers candidates from existing values
- ForeignKey columns are added by the string representation instead of its id number
- Hide columns to fill by offering default values
- Delete button in the UPDATE field
Requirements
All the requirements you should probably have anyway.
- streamlit and sqlalchemy
- Sqlalchemy models needs a str method
- Id column should be called "id"
- Relationships should be added for all ForeignKey columns
Basic Usage
Install the package using pip:
pip install streamlit_sql
Define a ModelOpts and add it to the argument of show_sql_ui function:
from streamlit_sql import ModelOpts, show_sql_ui
conn = st.connection("sql", url="<db_url>")
model_opts = ModelOpts(MyModel)
show_sql_ui(conn, model_opts)
Customize
You can configure the CRUD interface by giving optional arguments to the ModelOpts object. See its docstring for more information or at documentation webpage:
Multiple Models
You can set the model_opts argument to a list of ModelOpts objects. In this case, a st.selectbox will let user to select the table to work on.
Only create or update form
You can display just a create or update/delete form without the read interface using functions show_updade, and show_create.
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
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file streamlit_sql-0.1.2.tar.gz.
File metadata
- Download URL: streamlit_sql-0.1.2.tar.gz
- Upload date:
- Size: 11.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.1 CPython/3.13.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
804186824193d392f78112e3ad3e92a602af5cc198a5ea69bfb7760abe31b48b
|
|
| MD5 |
d4d53c2860a9ff1a4c713dc7a16b8f14
|
|
| BLAKE2b-256 |
6634c010c7ce8652ed596d488f79ffe64bf62c54de27e730effd6308d391211e
|
File details
Details for the file streamlit_sql-0.1.2-py3-none-any.whl.
File metadata
- Download URL: streamlit_sql-0.1.2-py3-none-any.whl
- Upload date:
- Size: 11.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.1 CPython/3.13.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
000e723fc0257d3daf6126df24e231fc20378f726757a5221402584b43d920ee
|
|
| MD5 |
cf76577f52af31df5a0269fea32ac0df
|
|
| BLAKE2b-256 |
960ca0e0cc7efd36c6c6323ef3b5101568a1300c1c1eea341514464acffcaaca
|