PostgreSQL & SQL
PostgreSQL: The "Gold Standard" database for Python. It's powerful, open-source, and has great support for JSON data—perfect for storing ML model outputs.
SQLAlchemy ORM
python
from sqlalchemy.orm import DeclarativeBase, Mapped, mapped_column
class Base(DeclarativeBase):
pass
class User(Base):
__tablename__ = "users"
id: Mapped[int] = mapped_column(primary_key=True)
name: Mapped[str]
Redis Caching
Why Redis? If an ML prediction takes 2 seconds, we don't want to run it twice for the same input. We save the result in Redis (RAM) for instant retrieval.