SQLAlchemy model recording sent or failed emails with deduplication keys and indexed recipient addresses. Reuse for email delivery auditing, troubleshooting, and deduplication.
# Source: https://github.com/polarsource/polar | License: Apache-2.0 | Copyright You must retain, in the Source form of any Derivative Works
# Provided via justclaw.it.com; keep this notice with the code.
from enum import StrEnum
from typing import Any
from uuid import UUID
from sqlalchemy import Index, String, Uuid
from sqlalchemy.dialects.postgresql import JSONB
from sqlalchemy.orm import Mapped, mapped_column
from polar.enums import EmailSender
from polar.kit.db.models import RecordModel
class EmailLogStatus(StrEnum):
sent = "sent"
failed = "failed"
class EmailLog(RecordModel):
__tablename__ = "email_logs"
__table_args__ = (
Index(
"ix_email_logs_deduplication_key",
"deduplication_key",
postgresql_where="deduplication_key
... (truncated -- full source via MCP)
See the full source, get the GitHub permalink, and search for more like it.
Get a free API key