Friday, 16 February 2024

pdict: Persistent dict (python)

from sqlitedict import SqliteDict
import sqlite3

def pdict(db_path:str|Path):
    if not isinstance(db_path, Path):
        db_path = Path(db_path)
    if not db_path.exists():
        db_path.parent.mkdir(exist_ok=True, parents=True)
        conn = sqlite3.connect(db_path)
        conn.execute('PRAGMA journal_mode=WAL;')
        conn.commit()
        conn.close()
    return SqliteDict(db_path, autocommit=True)

No comments:

Post a Comment

Iterative Mona Lisa E2E development

Iterative as at the beginning I know least Mona Lisa, as I always want to be able to stop E2E, go wide before going deep Notes: Agents are i...