Skip to main content

Some templating for streamlit and sqlalchemy

Project description

streamlit-sqlalchemy

Some templating for streamlit and sqlalchemy

streamlit-sql-crud

Status & Objectives

  • Integer fields
  • String fields
  • Many2One
  • Many2Many

Usage

python3 -m pip install streamlit-sqlalchemy
python3 -m streamlit run example.py

Add the mixin to your SQLAlchemy defined class

# sqlalchemy stuff
Base = declarative_base()
engine = create_engine("sqlite:///db.sqlite3")

class Awesome(Base, StreamlitAlchemyMixin):
    __tablename__ = "awesome"

    id = Column(Integer, primary_key=True)
    name = Column(String)
    other_field = Column(Integer)

Then you need to link the Mixin with the Base, in order to have access to the foreign keys. And to the engine for access to the database.

# Must be called before any other method
StreamlitAlchemyMixin.sam_initialize(Base, engine)

Then you have access to streamlit components.

# The classic 3 tabs
Awesome.sam_crud_tabs()

# Create
Awesome.sam_create_form()

# Update with a select choice on top
Awesome.sam_update_select_form()

# Delete with a select choice on top
Awesome.sam_delete_select_form()

for awesome in Awesome.sam_get_all():
    # Update a single element
    awesome.sam_update_form()

    # Delete an element
    awesome.sam_delete_button()

Contribute

You are welcome to contribute!

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

streamlit_sqlalchemy-0.0.3.tar.gz (45.5 kB view details)

Uploaded Source

Built Distribution

streamlit_sqlalchemy-0.0.3-py3-none-any.whl (8.2 kB view details)

Uploaded Python 3

File details

Details for the file streamlit_sqlalchemy-0.0.3.tar.gz.

File metadata

  • Download URL: streamlit_sqlalchemy-0.0.3.tar.gz
  • Upload date:
  • Size: 45.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.6

File hashes

Hashes for streamlit_sqlalchemy-0.0.3.tar.gz
Algorithm Hash digest
SHA256 e31b1e67845f41ce93f4a196d0cb5176b57b2cdd68e46bd81c4e65b52dc258a4
MD5 f584bf05d5b70e627eb5a09aea4112fe
BLAKE2b-256 68e44df7192800526e550b4e7d7c1db1c2056d78da0be2a133415feaffa3eaff

See more details on using hashes here.

File details

Details for the file streamlit_sqlalchemy-0.0.3-py3-none-any.whl.

File metadata

File hashes

Hashes for streamlit_sqlalchemy-0.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 e343ec2e60115a3746d3be59944c4494e49f88e84f9eeb7685672bcd95a14670
MD5 6c236b3c22837c82303012b0c36cd072
BLAKE2b-256 b789edefa867269e32903fcdb5ce4ed1270041933306955e737e4367d13ba339

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page