Add full database backup and restoration scripts for exact original recipes
This commit is contained in:
@@ -0,0 +1,41 @@
|
||||
import os
|
||||
import sys
|
||||
|
||||
sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
|
||||
from app.database import get_connection, CHAPTERS
|
||||
|
||||
sys.stdout.reconfigure(encoding='utf-8')
|
||||
|
||||
conn = get_connection()
|
||||
cur = conn.cursor()
|
||||
|
||||
# Normalize categories
|
||||
cur.execute("UPDATE recipes SET category = 'Traditionell & Basics' WHERE id = 104")
|
||||
cur.execute("UPDATE recipes SET category = 'Asiatische Küche' WHERE id IN (103, 107, 108, 109)")
|
||||
conn.commit()
|
||||
|
||||
# Ensure all recipes have notes = ""
|
||||
cur.execute("UPDATE recipes SET notes = '' WHERE notes IS NOT NULL AND notes != ''")
|
||||
conn.commit()
|
||||
|
||||
# Verify
|
||||
cur.execute("SELECT id, title, category, chapter_number, notes FROM recipes ORDER BY chapter_number, title")
|
||||
rows = cur.fetchall()
|
||||
|
||||
print(f"Total recipes: {len(rows)}")
|
||||
notes_count = sum(1 for r in rows if r['notes'])
|
||||
print(f"Non-empty notes count: {notes_count}")
|
||||
|
||||
chap_counts = {}
|
||||
for r in rows:
|
||||
c = r['category']
|
||||
chap_counts[c] = chap_counts.get(c, 0) + 1
|
||||
|
||||
print("\nFinal Chapters & Counts:")
|
||||
for ch in CHAPTERS:
|
||||
title = ch['title']
|
||||
num = ch['number']
|
||||
cnt = chap_counts.get(title, 0)
|
||||
print(f" Kapitel {num:2d}: {title:25s} -> {cnt:2d} Rezepte")
|
||||
|
||||
conn.close()
|
||||
Reference in New Issue
Block a user