Attender / fix_sql_quotes.py
chualinwei3's picture
Upload 30 files
f742815 verified
Raw
History Blame Contribute Delete
722 Bytes
import re
file_path = 'attendr.sql'
with open(file_path, 'r', encoding='utf-8') as f:
content = f.read()
# Replace "table_name" with `table_name` in INSERT INTO statements
# Regex looks for: INSERT INTO "word"
# Replaces with: INSERT INTO `word`
# Or I can just remove the quotes since table names are safe. Let's remove them to be safe across different modes if possible, but backticks are safer for MySQL.
# Let's use backticks.
def replace_quotes(match):
return f'INSERT INTO `{match.group(1)}`'
new_content = re.sub(r'INSERT INTO "([^"]+)"', replace_quotes, content)
with open(file_path, 'w', encoding='utf-8') as f:
f.write(new_content)
print("Fixed quotes in attendr.sql")