Introduce thin wrapper for SQL calls
All checks were successful
Mypy / mypy (push) Successful in 1m11s
Pytest / pytest (3.12) (push) Successful in 1m19s
Pytest / pytest (3.13) (push) Successful in 1m14s
Pytest / pytest (3.14) (push) Successful in 1m16s
Ruff / ruff (push) Successful in 1m3s
Mypy / mypy (pull_request) Successful in 1m13s
Pytest / pytest (3.12) (pull_request) Successful in 1m18s
Pytest / pytest (3.13) (pull_request) Successful in 1m12s
Pytest / pytest (3.14) (pull_request) Successful in 1m15s
Ruff / ruff (pull_request) Successful in 1m0s

This commit is contained in:
Justus Kuhlmann 2026-04-21 10:22:46 +02:00
commit d6de8e6387
Signed by: jkuhl
GPG key ID: 00ED992DD79B85A6
3 changed files with 35 additions and 16 deletions

17
corrlib/sql.py Normal file
View file

@ -0,0 +1,17 @@
import sqlite3
from .tools import get_db_file
from pathlib import Path
from typing import Any
def thin_sql_wrapper(path: Path, stmt: str) -> list[Any]:
db_file = get_db_file(path)
db = path / db_file
conn = sqlite3.connect(db)
c = conn.cursor()
c.execute(stmt)
results = c.fetchall()
conn.commit()
conn.close()
return results