Fixed dev environment database setup

This commit is contained in:
Philip Zimmermann
2025-12-13 18:26:56 +01:00
parent 705e19701f
commit e94962ccbb
3 changed files with 12 additions and 7 deletions
+3 -2
View File
@@ -4,7 +4,8 @@ import zlib
import sqlite3
from pathlib import Path
from typing import List
from .utils import update_data
from .utils import update_data, DB_PATH
# Full list of expected sizes
EXPECTED_SIZES = [
@@ -188,7 +189,7 @@ def lookup_crc(crc_bytes: bytes, logs: List[str]) -> List[tuple[int, int]]:
Queries the SQLite DB for the CRC and returns a list of (width, height) tuples.
"""
# Locate DB relative to this script file
db_path = Path(__file__).parent / "ihdr_crcs.db"
db_path = Path(DB_PATH)
if not db_path.exists():
logs.append(f"Error: Database not found at {db_path}")
+5 -3
View File
@@ -64,10 +64,12 @@ def create_crc_db() -> None:
if os.path.exists(DB_PATH):
print(f"Database already exists at {DB_PATH}. Skipping generation.")
return
db_filename = "ihdr_crcs.db"
# Connect to database
conn = sqlite3.connect(db_filename)
# Use the global DB_PATH variable so it writes to /data/ in Docker
# and /analyzers/ in local dev
print(f"Generating database at: {DB_PATH}")
conn = sqlite3.connect(DB_PATH)
cursor = conn.cursor()
# Optimization: Turn off safety checks for bulk insertion speed