first commit
This commit is contained in:
@@ -0,0 +1,58 @@
|
||||
# %%
|
||||
import re
|
||||
|
||||
# %%
|
||||
with open("./log.txt",encoding="utf-8") as f:
|
||||
log = f.read()
|
||||
|
||||
# %%
|
||||
preparing_pattern = r'Preparing: (.*)'
|
||||
parameters_pattern = r'Parameters: (.*)'
|
||||
preparing_match = re.search(preparing_pattern, log)
|
||||
parameters_match = re.search(parameters_pattern, log)
|
||||
|
||||
# %%
|
||||
sql = preparing_match.group(1)
|
||||
|
||||
# %%
|
||||
values = parameters_match.group(1)
|
||||
|
||||
# %%
|
||||
result_type = []
|
||||
for i in values.split(","):
|
||||
pattern = r'\((.*?)\)'
|
||||
srg = re.findall(pattern,i)
|
||||
# try:
|
||||
if len(srg)==1:
|
||||
result_type.append(srg[0].strip())
|
||||
else:
|
||||
result_type.append(i.strip())
|
||||
|
||||
# %%
|
||||
result_type
|
||||
|
||||
# %%
|
||||
result = re.sub(r'\((.*?)\)', '',values).split(",")
|
||||
|
||||
# %%
|
||||
result_type.append(" ")
|
||||
|
||||
# %%
|
||||
result.append(" ")
|
||||
|
||||
# %%
|
||||
len(sql.split("?"))
|
||||
|
||||
# %%
|
||||
sql_final = ""
|
||||
for i,k in enumerate(sql.split("?")):
|
||||
if result_type[i] == "String" or result_type[i] == "Timestamp":
|
||||
sql_final += k + "'" + result[i].strip() + "'"
|
||||
else:
|
||||
sql_final += k + result[i].strip()
|
||||
print(sql_final)
|
||||
input()
|
||||
# %%
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user