- UI.pageInfo(): generische Hilfe-Funktion — erstes Öffnen zeigt Info-Banner, danach ? Button oben rechts; CSS-Klassen pinfo-* - Übungen-Seite nutzt UI.pageInfo() als erstes Beispiel - Karte POI: Mehrfachauswahl (außer Giftköder), Kombi-Typen entfernt, type als comma-separated im Backend - daily_quotes Tabelle in DB (346 Einträge via import_quotes.py importiert) - GET /widget/quote — deterministischer Tagesspruch (wechselt täglich)
24 lines
841 B
Python
24 lines
841 B
Python
#!/usr/bin/env python3
|
|
"""Importiert dog_quotes.json in die daily_quotes-Tabelle."""
|
|
import json, sqlite3, sys
|
|
from pathlib import Path
|
|
|
|
DB_PATH = Path(__file__).parent.parent / 'backend' / 'banyaro.db'
|
|
JSON_PATH = Path(__file__).parent / 'dog_quotes.json'
|
|
|
|
quotes = json.loads(JSON_PATH.read_text())
|
|
conn = sqlite3.connect(DB_PATH)
|
|
|
|
existing = conn.execute("SELECT COUNT(*) FROM daily_quotes").fetchone()[0]
|
|
if existing > 0:
|
|
print(f"{existing} Einträge bereits vorhanden — überspringe Import.")
|
|
print("Zum Neuimport: DELETE FROM daily_quotes; zuerst ausführen.")
|
|
sys.exit(0)
|
|
|
|
conn.executemany(
|
|
"INSERT INTO daily_quotes (text, autor, kategorie) VALUES (?, ?, ?)",
|
|
[(q['text'], q.get('autor'), q.get('kategorie')) for q in quotes]
|
|
)
|
|
conn.commit()
|
|
print(f"{len(quotes)} Tagessprüche importiert.")
|
|
conn.close()
|