malepati/custom_template_working
0
1import sqlite32import json3 4db_path = r"c:\Users\DELL\Documents\upgrading\Accusaga_slides_presentation\servers\fastapi\app_data\fastapi.db"5 6conn = sqlite3.connect(db_path)7cursor = conn.cursor()8 9# 1. Get column names for slides10cursor.execute("PRAGMA table_info(slides);")11s_cols = [c[1] for c in cursor.fetchall()]12 13# 2. Find the slide14cursor.execute("SELECT * FROM slides")15rows = cursor.fetchall()16search_label = "Bipolar Disorder in MDD"17target_pid = None18target_lid = None19 20for row in rows:21 rd = dict(zip(s_cols, row))22 content_str = rd.get('content')23 if content_str:24 try:25 content = json.loads(content_str)26 if "chart" in content:27 for item in content["chart"].get("data", []):28 if search_label in str(item.get("label", "")):29 target_pid = rd.get('presentation')30 target_lid = rd.get('layout_id')31 break32 except:33 pass34 35if target_pid and target_lid:36 print(f"Found! PID: {target_pid}, LID: {target_lid}")37 # Normalize PID (it might be a string with dashes or without)38 39 # 3. Get layout code40 cursor.execute("PRAGMA table_info(presentation_layout_codes);")41 p_cols = [c[1] for c in cursor.fetchall()]42 43 # Try multiple ways to match PID if needed, but start exact44 cursor.execute("SELECT layout_code FROM presentation_layout_codes WHERE presentation = ? AND layout_id = ?", (target_pid, target_lid))45 res = cursor.fetchone()46 if not res:47 # Try normalized48 cursor.execute("SELECT presentation, layout_id, layout_code FROM presentation_layout_codes")49 all_codes = cursor.fetchall()50 for p, l, c in all_codes:51 if p.replace("-", "") == target_pid.replace("-", "") and l == target_lid:52 res = (c,)53 break54 55 if res:56 with open("problematic_layout.tsx", "w", encoding="utf-8") as f:57 f.write(res[0])58 print("Success: saved problematic_layout.tsx")59 else:60 print("Failed to find layout code.")61else:62 print("Slide not found.")63 64conn.close()65 