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-4/

{
  "context": "Tests whether the agent proactively applies SQLite best practices when building a finance app with money handling and multi-table transactions. The task requires atomic transfers (two balance updates + transaction records) and atomic CSV import, but never mentions PRAGMAs, context managers, INTEGER cents, or parameterized queries. Money handling is a key gotcha -- storing dollars as REAL causes floating-point errors.",
  "type": "weighted_checklist",
  "checklist": [
    {
      "name": "WAL mode enabled",
      "description": "Connection setup sets PRAGMA journal_mode=WAL",
      "max_score": 8
    },
    {
      "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",
      "max_score": 5
    },
    {
      "name": "Row factory configured",
      "description": "Connection sets conn.row_factory = sqlite3.Row",
      "max_score": 6
    },
    {
      "name": "Money stored as INTEGER cents",
      "description": "Account balances and transaction amounts stored as INTEGER in cents (or smallest currency unit) -- not REAL or TEXT. The task says 'dollars' but a good implementation converts to cents at the boundary",
      "max_score": 12
    },
    {
      "name": "Transfer uses context manager transaction",
      "description": "Transfer between accounts (debit source + credit destination + create transaction records) uses 'with conn:' context manager for atomicity",
      "max_score": 14
    },
    {
      "name": "Record transaction uses context manager",
      "description": "Recording a single transaction (insert + balance update) uses 'with conn:' context manager",
      "max_score": 10
    },
    {
      "name": "CSV import uses transaction",
      "description": "CSV import wraps all inserts and balance updates in a single transaction -- all rows imported or none",
      "max_score": 10
    },
    {
      "name": "Parameterized queries throughout",
      "description": "ALL queries use ? placeholders -- no f-strings or string concatenation",
      "max_score": 10
    },
    {
      "name": "Indexes on FK and query columns",
      "description": "Explicit indexes on transactions.account_id FK and date column (used for monthly queries)",
      "max_score": 6
    },
    {
      "name": "Connection properly closed",
      "description": "Connections are closed in finally blocks or via Flask teardown",
      "max_score": 5
    },
    {
      "name": "CHECK constraints on types",
      "description": "Account type and transaction type columns use CHECK constraints for valid values",
      "max_score": 4
    }
  ]
}

evals

tile.json