CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl-labs/sqlalchemy-best-practices

SQLAlchemy patterns — engine setup, session management, declarative models,

98

1.96x
Quality

99%

Does it follow best practices?

Impact

98%

1.96x

Average score across 5 eval scenarios

SecuritybySnyk

Passed

No known issues

Overview
Quality
Evals
Security
Files

criteria.jsonevals/scenario-3/

{
  "context": "Tests whether the agent proactively applies bulk insert patterns, IntegrityError handling, and production engine configuration when building a high-volume import service. The task mentions efficiency and skip-on-duplicate but does not prescribe specific SQLAlchemy patterns.",
  "type": "weighted_checklist",
  "checklist": [
    {
      "name": "Bulk insert used (not individual add in loop)",
      "description": "The import function uses a bulk pattern -- insert() with a list of dicts, add_all with batching, or batch-wise processing -- rather than calling session.add() individually for each of thousands of rows. The task said 'should be efficient' but did not specify how.",
      "max_score": 16
    },
    {
      "name": "IntegrityError caught for duplicate SKU",
      "description": "Duplicate SKU handling uses try/except IntegrityError with db.rollback() to gracefully skip duplicates, or uses an INSERT ... ON CONFLICT pattern. The task said 'skip it' but did not mention IntegrityError.",
      "max_score": 14
    },
    {
      "name": "pool_pre_ping enabled",
      "description": "Engine created with pool_pre_ping=True.",
      "max_score": 8
    },
    {
      "name": "Pool size and overflow configured",
      "description": "Engine specifies pool_size, max_overflow, and pool_recycle for production use.",
      "max_score": 8
    },
    {
      "name": "Mapped types used (not Column)",
      "description": "Models use Mapped[type] = mapped_column(...), not legacy Column().",
      "max_score": 10
    },
    {
      "name": "Session yield/finally cleanup",
      "description": "Session dependency uses yield with finally or a context manager for cleanup.",
      "max_score": 8
    },
    {
      "name": "No raw SQL f-strings",
      "description": "Any raw SQL uses text() with :bound_params. No f-strings or string concatenation for query building.",
      "max_score": 10
    },
    {
      "name": "Database URL from environment",
      "description": "Database URL read from an environment variable, not hardcoded.",
      "max_score": 6
    },
    {
      "name": "DeclarativeBase used",
      "description": "Base class uses DeclarativeBase, not legacy declarative_base().",
      "max_score": 6
    },
    {
      "name": "expire_on_commit=False",
      "description": "sessionmaker configured with expire_on_commit=False.",
      "max_score": 8
    },
    {
      "name": "back_populates on relationships",
      "description": "Category-Product relationship uses back_populates, not backref.",
      "max_score": 6
    }
  ]
}

evals

tile.json