19 lines
561 B
Python
19 lines
561 B
Python
import re
|
|
|
|
# 读取文件
|
|
file_path = r'd:\work\java-space\deploy-ease-platform\backend\src\main\resources\db\changelog\changes\v1.0.0-data.sql'
|
|
|
|
with open(file_path, 'r', encoding='utf-8') as f:
|
|
content = f.read()
|
|
|
|
# 替换时间戳为 NOW()
|
|
# 匹配格式: 'YYYY-MM-DD HH:MM:SS' 或 'YYYY-MM-DD HH:MM:SS.ffffff'
|
|
pattern = r"'[0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}:[0-9]{2}(\.[0-9]+)?'"
|
|
new_content = re.sub(pattern, 'NOW()', content)
|
|
|
|
# 写回文件
|
|
with open(file_path, 'w', encoding='utf-8') as f:
|
|
f.write(new_content)
|
|
|
|
print("替换完成!")
|