CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl-labs/sqlite-python-best-practices

SQLite best practices for Python -- PRAGMAs per connection, context manager transactions, parameterized queries, row_factory, executemany, FK indexes

92

1.73x
Quality

90%

Does it follow best practices?

Impact

97%

1.73x

Average score across 5 eval scenarios

SecuritybySnyk

Passed

No known issues

Overview
Quality
Evals
Security
Files

criteria.jsonevals/scenario-2/

{
  "context": "Tests whether the agent proactively applies SQLite best practices for a concurrent-access scenario. The task mentions 'concurrent requests' as a business concern but never prescribes WAL mode, busy_timeout, or transaction patterns. Registration requires an atomic check-and-insert to prevent overbooking. Cancel-and-promote requires a multi-step transaction. Bulk create tests executemany. The task never mentions PRAGMAs, context managers, or parameterized queries.",
  "type": "weighted_checklist",
  "checklist": [
    {
      "name": "WAL mode enabled",
      "description": "Connection setup sets PRAGMA journal_mode=WAL -- essential for the concurrent reads mentioned in the task",
      "max_score": 10
    },
    {
      "name": "Foreign keys ON",
      "description": "Connection setup sets PRAGMA foreign_keys=ON per connection",
      "max_score": 10
    },
    {
      "name": "Busy timeout set",
      "description": "Connection setup sets PRAGMA busy_timeout to a positive value -- important since the task mentions concurrent requests",
      "max_score": 8
    },
    {
      "name": "Row factory configured",
      "description": "Connection sets conn.row_factory = sqlite3.Row for dict-like access",
      "max_score": 6
    },
    {
      "name": "Registration uses atomic transaction",
      "description": "Registering for an event (capacity check + insert) uses 'with conn:' context manager so the check and insert are atomic -- prevents race condition where two requests both see capacity available",
      "max_score": 14
    },
    {
      "name": "Cancel-and-promote uses transaction",
      "description": "Cancelling a registration and promoting from waitlist happens in a single 'with conn:' transaction -- both the cancel and promote succeed or neither does",
      "max_score": 12
    },
    {
      "name": "Bulk create uses transaction",
      "description": "Bulk event creation wraps all inserts in a single transaction so all succeed or all fail",
      "max_score": 8
    },
    {
      "name": "Parameterized queries throughout",
      "description": "ALL queries use ? placeholders -- no f-strings or string concatenation",
      "max_score": 10
    },
    {
      "name": "UNIQUE constraint on member+event",
      "description": "Schema has a UNIQUE constraint on (member_id, event_id) or equivalent to prevent duplicate registrations at the database level",
      "max_score": 6
    },
    {
      "name": "Indexes on FK columns",
      "description": "Explicit indexes on registrations.event_id and registrations.member_id foreign key columns",
      "max_score": 6
    },
    {
      "name": "Connection properly managed",
      "description": "Connections are properly closed in finally blocks or via dependency injection lifecycle",
      "max_score": 5
    },
    {
      "name": "CHECK constraint on status",
      "description": "Status columns use CHECK constraints to enforce valid values",
      "max_score": 5
    }
  ]
}

evals

tile.json