使用python写了一个sql填充工具_sql

import tkinter as tk
from tkinter import ttk, scrolledtext

def fill_template():
    old_id = old_id_entry.get()
    new_id = new_id_entry.get()
    old_code = old_code_entry.get()
    new_code = new_code_entry.get()
    old_name = old_name_entry.get()
    new_name = new_name_entry.get()
    district_code = district_code_entry.get()
    province_city_district = province_city_district_entry.get()
    manage_gbcode = district_code_entry.get()
    manageorg_name = new_name_entry.get()
    p3_code = manage_gbcode[:2]
    c3_code = manage_gbcode[2:4]
    d3_code = manage_gbcode[4:6]
    s3_code = manage_gbcode[6:]
    sql_template = f"""
-- 3. Delete organization and clear user integration information
update roar_psy.organizations o set o.status = '1' where o.org_id = {old_id}; 
update roar_psy.users t
   set t.last_upload_message = '', t.is_async = '', t.is_pass = ''
 where t.org_id = {old_id};
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
-- 4. Process business data
-- Management organization 
-- Check 1
select count(*) from t_a_Disease_Info t where t.manageorg_id = {old_id};
       
-- 1. Basic information
update t_a_Disease_Info t
   set t.manageorg_code      = '{new_code}',
       t.manageorg_code_tmp  = '',
       t.manageorg_gbcode    = '{district_code}',
       t.manageorg_name      = '{new_name}',
       t.is_grab             = '',
       t.last_upload_message = '',
       t.grab_date           = t.modify_date, t.manageorg_id = {new_id}
 where t.manageorg_id = {old_id};
 -- Check 2
select count(*) from t_a_Disease_Info t where t.manageorg_id = {old_id};
-- More update statements...
"""
    output_text.delete('1.0', tk.END)
    output_text.insert(tk.INSERT, sql_template)

root = tk.Tk()
root.title("SQL Template Filler")

ttk.Label(root, text="Old Org ID:").grid(column=0, row=0)
old_id_entry = ttk.Entry(root)
old_id_entry.grid(column=1, row=0)

ttk.Label(root, text="New Org ID:").grid(column=0, row=1)
new_id_entry = ttk.Entry(root)
new_id_entry.grid(column=1, row=1)

ttk.Label(root, text="Old Org Code:").grid(column=0, row=2)
old_code_entry = ttk.Entry(root)
old_code_entry.grid(column=1, row=2)

ttk.Label(root, text="New Org Code:").grid(column=0, row=3)
new_code_entry = ttk.Entry(root)
new_code_entry.grid(column=1, row=3)

ttk.Label(root, text="Old Org Name:").grid(column=0, row=4)
old_name_entry = ttk.Entry(root)
old_name_entry.grid(column=1, row=4)

ttk.Label(root, text="New Org Name:").grid(column=0, row=5)
new_name_entry = ttk.Entry(root)
new_name_entry.grid(column=1, row=5)

ttk.Label(root, text="New District Code:").grid(column=0, row=6)
district_code_entry = ttk.Entry(root)
district_code_entry.grid(column=1, row=6)

ttk.Label(root, text="New Province/City/District:").grid(column=0, row=7)
province_city_district_entry = ttk.Entry(root)
province_city_district_entry.grid(column=1, row=7)

fill_button = ttk.Button(root, text="Fill Template", command=fill_template)
fill_button.grid(column=1, row=8)

output_text = scrolledtext.ScrolledText(root, width=80, height=20)
output_text.grid(column=0, row=9, columnspan=2)

root.mainloop()