refactor: Move maintenance scripts to a dedicated maintenance_scripts/ directory.
This commit is contained in:
42
maintenance_scripts/debug_db.py
Normal file
42
maintenance_scripts/debug_db.py
Normal file
@@ -0,0 +1,42 @@
|
||||
import sqlite3
|
||||
import os
|
||||
|
||||
def debug_db():
|
||||
db_path = os.path.join(os.path.dirname(os.path.dirname(os.path.abspath(__file__))), "database", "umamusume.db")
|
||||
if not os.path.exists(db_path):
|
||||
print(f"Database not found at {db_path}")
|
||||
return
|
||||
|
||||
conn = sqlite3.connect(db_path)
|
||||
cur = conn.cursor()
|
||||
|
||||
print("--- Database Debug ---")
|
||||
|
||||
cur.execute("SELECT COUNT(*) FROM support_cards")
|
||||
print(f"Total support cards: {cur.fetchone()[0]}")
|
||||
|
||||
cur.execute("SELECT COUNT(*) FROM owned_cards")
|
||||
owned_count = cur.fetchone()[0]
|
||||
print(f"Owned cards count: {owned_count}")
|
||||
|
||||
cur.execute("""
|
||||
SELECT oc.card_id, sc.name
|
||||
FROM owned_cards oc
|
||||
LEFT JOIN support_cards sc ON oc.card_id = sc.card_id
|
||||
""")
|
||||
rows = cur.fetchall()
|
||||
|
||||
print("\nOwned cards details:")
|
||||
for card_id, name in rows:
|
||||
print(f" ID: {card_id}, Name: {name}")
|
||||
|
||||
orphaned = [row[0] for row in rows if row[1] is None]
|
||||
if orphaned:
|
||||
print(f"\nFound {len(orphaned)} orphaned owned cards (Card IDs: {orphaned})")
|
||||
else:
|
||||
print("\nNo orphaned owned cards found.")
|
||||
|
||||
conn.close()
|
||||
|
||||
if __name__ == "__main__":
|
||||
debug_db()
|
||||
Reference in New Issue
Block a user