malepati/custom_template_working
0
1import sqlite32 3src_db = r"c:\Users\DELL\Documents\upgrading\Accusaga_slides_presentation\servers\fastapi\app_data\fastapi.db"4dst_db = r"c:\Users\DELL\Documents\upgrading\Accusaga_slides_presentation\servers\fastapi\app_data\container.db"5 6def get_schema(db_path, table_name):7 conn = sqlite3.connect(db_path)8 cursor = conn.cursor()9 cursor.execute(f"SELECT sql FROM sqlite_master WHERE type='table' AND name='{table_name}'")10 schema = cursor.fetchone()11 conn.close()12 return schema[0] if schema else None13 14def create_table(db_path, schema_sql):15 conn = sqlite3.connect(db_path)16 cursor = conn.cursor()17 try:18 cursor.execute(schema_sql)19 conn.commit()20 print(f"Successfully created table in {db_path}")21 except Exception as e:22 print(f"Error creating table: {e}")23 finally:24 conn.close()25 26# 1. Get schema for presentation_layout_codes27schema = get_schema(src_db, "presentation_layout_codes")28if schema:29 print(f"Found schema: {schema}")30 # 2. Check if it exists in dest31 existing = get_schema(dst_db, "presentation_layout_codes")32 if not existing:33 print("Table missing in container.db. Creating...")34 create_table(dst_db, schema)35 else:36 print("Table already exists in container.db")37else:38 print("Could not find source table schema!")39 