import re

with open('wbmczonl_MCZ1555.sql', 'r', encoding='utf-8', errors='ignore') as f:
    content = f.read()
    
tables = re.findall(r'CREATE TABLE.*?\(.*?;', content, re.IGNORECASE | re.DOTALL)
with open('extracted_schema.sql', 'w', encoding='utf-8') as out:
    for t in tables:
        out.write(t + '\n\n')

print(f"Extracted {len(tables)} tables to extracted_schema.sql")
