Some templating for streamlit and sqlalchemy
Project description
streamlit-sqlalchemy
Some templating for streamlit and sqlalchemy
Usage
Add the mixin to your SQLAlchemy defined classes and you will have access to basic streamlit components.
from pathlib import Path
import streamlit as st
from sqlalchemy import Column, Integer, String, create_engine
from sqlalchemy.orm import declarative_base
from streamlit_sqlalchemy import StreamlitAlchemyMixin
Base = declarative_base()
class Awesome(Base, StreamlitAlchemyMixin):
__tablename__ = "car_brand"
id = Column(Integer, primary_key=True)
name = Column(String)
# The usual SQLAlchemy stuff
should_init = not Path("db.sqlite3").exists()
engine = create_engine("sqlite:///db.sqlite3")
if should_init:
Base.metadata.create_all(engine)
# Must be called before any other method
StreamlitAlchemyMixin.sam_initialize(Base, engine)
Awesome.sam_create_form()
Awesome.sam_update_form()
Awesome.sam_delete_form()
Awesome.sam_crud_tabs()
for awesome in Awesome.sam_get_all():
st.write(awesome.name)
awesome.delete_button()
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
Close
Hashes for streamlit_sqlalchemy-0.0.1.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7c9b755f4de08e7596b54360e2fa057a1ff45dfc80bddb05bce97bb51a1b6f5a |
|
MD5 | 47c08057cd1034a190239d7bdac7ad1b |
|
BLAKE2b-256 | a7cb8ea904f623e4ddeb9bc4d1de48f36280dace5607989b241ad96bd340bc12 |
Close
Hashes for streamlit_sqlalchemy-0.0.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 774633a19ee95abbfa43fea9a1ff0c34e8e37d29a54b687c8fbeed0dfba0cdb9 |
|
MD5 | 55ff28b9637378111520f0bce95f3aca |
|
BLAKE2b-256 | 763b7af5d653439952a642bfb6af60548cac17300be08f60d9b214dd9679d68d |