import os
os.chdir(os.path.dirname(os.path.abspath(__file__)))
with open('gw_dm.sql', 'r', encoding='utf-8') as f:
    content = f.read()
# Fix backslash-escaped single quotes: \' -> ''
content = content.replace("\\'ry\\'", "''ry''")
content = content.replace("\\'", "''")
# Remove any trailing ''; artifacts from earlier sed
content = content.replace("'');''", "'');")
with open('gw_dm.sql', 'w', encoding='utf-8') as f:
    f.write(content)
print('Done')
