streamlit_sqlalchemy is a Python module that provides seamless integration between Streamlit and SQLAlchemy models. It simplifies the process of creating, updating, and deleting database objects through Streamlit’s user-friendly interface.
Features
Easy Initialization: Initialize the SQLAlchemy connection with a simple method call.
CRUD Operations: Create, read, update, and delete operations are streamlined with minimal code.
Dynamic Forms: Automatically generate forms for creating and updating database objects.
Foreign Key Support: Easily handle foreign key relationships in forms.
Installation
pip install streamlit_sqlalchemy
Usage
Initialize the Engine:
from streamlit_sqlalchemy import StreamlitAlchemyMixin
# Create your SQLAlchemy model
class YourModel(Base, StreamlitAlchemyMixin):
__tablename__ = "your_model"
id = Column(Integer, primary_key=True)
# Other columns...
# Initialize the connection
StreamlitAlchemyMixin.st_initialize(connection=conn)
Hi, i found your project through github researching exactly how to be more efficient with crud/sqlalchemy etc. I think this is nice playbuddy to the streamlit-pydantic library.
Many exciting expansions come to mind.
Interacting with (or supercharging) the editable data_editor.
multi row editing (as someone also mentioned on the github)
Anyway, beautiful, I will work on some experiments.
I was wondering if it should also support UUIDs? (Given we are talking CRUDs)
Hey,
Thank you very much for your feedback, it means a lot!
I felt like the streamlit-pydantic library was not doing enough for my use case, but the tool is far from being perfect.
The expansions that you mentioned sound like very good ideas!
Interacting with the editable data_editor might be a little bit tricky with the current implementation, as everything is based on a naive CRUD approach for now.
Multi row editing is definitely a “must have”.
I don’t know why I didn’t implement the UUIDs yet, tbh. Might be because it is easy to add with a lambda.
As I said, it is far from being perfect, and I even wonder at times if it is good enough to be useful… If you struggle with anything or have a different opinion about how it should be interacted with, I’d be interested to know.
Do not hesitate to contribute if you feel like it.