feat: Implement new database management and scraping utilities, and update application version to 13.0.0.

This commit is contained in:
kiyreload27
2025-12-31 19:50:14 +00:00
parent d7d1318a55
commit a2ac99e8b6
22 changed files with 812 additions and 32 deletions

37
repair_db.py Normal file
View File

@@ -0,0 +1,37 @@
import sqlite3
import os
DB_PATH = os.path.join("database", "umamusume.db")
def repair_db():
if not os.path.exists(DB_PATH):
return
conn = sqlite3.connect(DB_PATH)
cur = conn.cursor()
print("Repairing database...")
# 1. Remove all orphans
cur.execute("DELETE FROM support_effects WHERE card_id NOT IN (SELECT card_id FROM support_cards)")
print(f"Removed {cur.rowcount} orphaned effects")
cur.execute("DELETE FROM support_hints WHERE card_id NOT IN (SELECT card_id FROM support_cards)")
print(f"Removed {cur.rowcount} orphaned hints")
cur.execute("DELETE FROM event_skills WHERE event_id NOT IN (SELECT event_id FROM support_events)")
print(f"Removed {cur.rowcount} orphaned event skills")
cur.execute("DELETE FROM support_events WHERE card_id NOT IN (SELECT card_id FROM support_cards)")
print(f"Removed {cur.rowcount} orphaned events")
# 2. Cleanup owned_cards and deck_slots
cur.execute("DELETE FROM owned_cards WHERE card_id NOT IN (SELECT card_id FROM support_cards)")
cur.execute("DELETE FROM deck_slots WHERE card_id NOT IN (SELECT card_id FROM support_cards)")
conn.commit()
conn.close()
print("Repair complete.")
if __name__ == "__main__":
repair_db()