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

python 复制代码
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()
相关推荐
孟健1 小时前
Karpathy 用 200 行纯 Python 从零实现 GPT:代码逐行解析
python
码路飞3 小时前
写了个 AI 聊天页面,被 5 种流式格式折腾了一整天 😭
javascript·python
倔强的石头_4 小时前
kingbase备份与恢复实战(二)—— sys_dump库级逻辑备份与恢复(Windows详细步骤)
数据库
曲幽6 小时前
FastAPI压力测试实战:Locust模拟真实用户并发及优化建议
python·fastapi·web·locust·asyncio·test·uvicorn·workers
敏编程10 小时前
一天一个Python库:jsonschema - JSON 数据验证利器
python
前端付豪10 小时前
LangChain记忆:通过Memory记住上次的对话细节
人工智能·python·langchain
databook11 小时前
ManimCE v0.20.1 发布:LaTeX 渲染修复与动画稳定性提升
python·动效
花酒锄作田1 天前
使用 pkgutil 实现动态插件系统
python
前端付豪1 天前
LangChain链 写一篇完美推文?用SequencialChain链接不同的组件
人工智能·python·langchain
曲幽1 天前
FastAPI实战:打造本地文生图接口,ollama+diffusers让AI绘画更听话
python·fastapi·web·cors·diffusers·lcm·ollama·dreamshaper8·txt2img