Spaces:
Sleeping
Sleeping
Download src/adapters/persistence/artifact_sqlite.py from dellweb3/VibeCoding: direct link, hf CLI and curl.
- Browser
- Download file 910 Bytes
-
https://huggingface.co/spaces/dellweb3/VibeCoding/resolve/main/src/adapters/persistence/artifact_sqlite.py
- Command line
-
hf download hf://spaces/dellweb3/VibeCoding/src/adapters/persistence/artifact_sqlite.py
-
curl -L -o artifact_sqlite.py https://huggingface.co/spaces/dellweb3/VibeCoding/resolve/main/src/adapters/persistence/artifact_sqlite.py
910 Bytes
| """SQLite implementation of immutable evidence object storage.""" | |
| import sqlite3 | |
| from pathlib import Path | |
| class SqliteArtifactRepository: | |
| def __init__(self, path): | |
| self.path = Path(path) | |
| self.path.parent.mkdir(parents=True, exist_ok=True) | |
| with sqlite3.connect(self.path) as db: | |
| db.execute('CREATE TABLE IF NOT EXISTS artifacts(tenant TEXT,run_id TEXT,digest TEXT,body TEXT,PRIMARY KEY(tenant,run_id,digest))') | |
| def put(self, tenant, run_id, key, body): | |
| with sqlite3.connect(self.path) as db: | |
| db.execute('INSERT OR IGNORE INTO artifacts VALUES(?,?,?,?)', (tenant, run_id, key, body)) | |
| def get(self, tenant, run_id, key): | |
| with sqlite3.connect(self.path) as db: | |
| row = db.execute('SELECT body FROM artifacts WHERE tenant=? AND run_id=? AND digest=?', (tenant, run_id, key)).fetchone() | |
| return row[0] if row else None | |