#!/usr/bin/env python3
import sqlite3, hashlib, os

db = '/opt/safesightd/data/app.db'
fg = '/opt/safesightd/resources/standard_resources/face_gallery/face_gallery.db'

sha = hashlib.sha256(open(fg, 'rb').read()).hexdigest()
size = os.path.getsize(fg)

conn = sqlite3.connect(db)
conn.execute(
    "INSERT OR REPLACE INTO standard_resources(name,resource_type,version,sha256,size_bytes,description,file_path,created_at,updated_at) VALUES(?,?,?,?,?,?,?,datetime('now'),datetime('now'))",
    ('face_gallery', 'face_gallery', 'v1', sha, size, '人脸库', 'resources/standard_resources/face_gallery/face_gallery.db'),
)
conn.commit()
conn.close()
print('OK sha256=' + sha + ' size=' + str(size))
