Some templating for streamlit and sqlalchemy
Project description
Streamlit SQLAlchemy Integration
Overview
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 engine 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.
- Tabbed Interface: Organize CRUD operations in a tabbed interface for better user experience.
- 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 fields # Initialize the engine StreamlitAlchemyMixin.st_initialize(engine)
-
CRUD Tabs:
YourModel.st_crud_tabs()
-
Customization:
Customize the behavior by overriding methods in your model.
class CustomModel(YourModel): # Override methods as needed
Example
import streamlit as st
from sqlalchemy import create_engine, Column, String, Integer
from sqlalchemy.ext.declarative import declarative_base
from streamlit_sqlalchemy import StreamlitAlchemyMixin
Base = declarative_base()
class ExampleModel(Base, StreamlitAlchemyMixin):
__tablename__ = "example"
id = Column(Integer, primary_key=True)
name = Column(String)
# Initialize the engine
engine = create_engine("sqlite:///example.db")
ExampleModel.st_initialize(engine)
# Create CRUD tabs
ExampleModel.st_crud_tabs()
Documentation
The project documentation is currently under development. Meanwhile, you can explore the provided example.
Contributing
We welcome contributions! See our contribution guidelines for more details.
License
This project is licensed under the Apache License 2.0 - see the LICENSE file for details.
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
Hashes for streamlit_sqlalchemy-0.0.5.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5eb7d167ad6f4b7dca4e356807b942574da45e61250881ec6951a1674140dc72 |
|
MD5 | 7cf3d8ff8c6c977a1c57b4db0cba9070 |
|
BLAKE2b-256 | 67dc136a6e1e1de38b2585f853fdfb2c0016dfe1f7e052e9eb2f5159a09513c6 |
Hashes for streamlit_sqlalchemy-0.0.5-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a333ad0abd208a871ecbb9a558501487f124e4696b887bcbd5bdc662e3ea249f |
|
MD5 | ad02df01b7aec565d5b9490a5faf23dc |
|
BLAKE2b-256 | a98b89713439e59717be54a77703060ddf1789f74b794908b2b50cf30aa0d7d7 |