吾爱破解 - LCG - LSG |安卓破解|病毒分析|www.52pojie.cn

 找回密码
 注册[Register]

QQ登录

只需一步,快速开始

查看: 2409|回复: 23
收起左侧

[Python 原创] 数据库的简易操作

  [复制链接]
菲矾啊 发表于 2023-9-22 16:18
最近配合搞测试,老是要帮他们清理数据
就想,能不能写个工具出来,让他们自己清理
我也能空出时间去做其他事(摸鱼)
然后就查资料啥的,初版出世。
但是发现,他们的内网桌面竟然连不上我的数据库,崩溃~
现在研究一下咋转成web,挂载服务器吧!
[Python] 纯文本查看 复制代码
import tkinter as tk
import cx_Oracle as cx

def run1():
    a = str(inp1.get())
    b = str(inp2.get())

    popup = tk.Toplevel()
    popup.title("提示")
    popup.geometry("230x80")

    if a=='':
        label = tk.Label(popup, text="身份证为空")
        label.pack(pady=10)
    elif b=='':
        label = tk.Label(popup, text="税号为空")
        label.pack(pady=10)
    else:''
    db = cx.connect('username/password@127.0.0.1:1521/prod')
    cursor = db.cursor()
    #sql = "update ACCOUT set yuliu='哈哈哈' where nsrsbh='"+b+"' and zjhm='"+a+"'"
    sql1 = "delete from table_name_a where nsrsbh='" + b + "'"
    sql2 = "delete from table_name_b where td_code='" + b + "'"
    sql3 = "delete from table_name_c where td_code='" + b + "'"
    sql4 = "delete from table_name_d where user_id='" + a + "'"
    cursor.execute(sql1)
    cursor.execute(sql2)
    cursor.execute(sql3)
    cursor.execute(sql4)
    db.commit()

    cursor.close()
    db.close()
    label = tk.Label(popup, text="已清除数据\n身份证号:" + a + "\n纳税号码:" + b,justify="center")
    label.pack(pady=10)
    inp1.delete(0, tk.END)
    inp2.delete(0, tk.END)

def run2():
    try:
        db = cx.connect('username/password@127.0.0.1:1521/prod')
        ver = str(db.version)
        lb4 = tk.Label(root, text='连接成功,版本号:'+ver,fg="green")
        lb4.place(relx=0.11, rely=0.87, relwidth=0.6, relheight=0.1)
    except:
        lb3 = tk.Label(root, text='连接失败,请检查环境!',fg="red")
        lb3.place(relx=0.11, rely=0.87, relwidth=0.6, relheight=0.1)
    finally:
        # 关闭数据库
        db.close()


root = tk.Tk()

#设置窗口属性
root.title("清除测试数据")
root.geometry("350x240")

lb = tk.Label(root, text='仅限测试环境使用!',fg="red",font=("Arial", 20),justify="center")
lb.place(relx=0, rely=0.12, relwidth=1.04, relheight=0.1)
lb1 = tk.Label(root, text='请输入身份证号')
lb1.place(relx=0, rely=0.3, relwidth=0.3, relheight=0.1)
inp1 = tk.Entry(root)
inp1.place(relx=0.3, rely=0.3, relwidth=0.6, relheight=0.1)
lb2 = tk.Label(root, text='输入纳税识别号')
lb2.place(relx=0, rely=0.5, relwidth=0.3, relheight=0.1)
inp2 = tk.Entry(root)
inp2.place(relx=0.3, rely=0.5, relwidth=0.6, relheight=0.1)

btn1 = tk.Button(root, text='清除数据', command=run1)
btn1.place(relx=0.5, rely=0.7, relwidth=0.3, relheight=0.15)
btn2 = tk.Button(root, text='测试连接', command=run2)
btn2.place(relx=0.12, rely=0.7, relwidth=0.3, relheight=0.15)

root.mainloop()


效果图:

免费评分

参与人数 3吾爱币 +7 热心值 +3 收起 理由
junjia215 + 1 + 1 谢谢@Thanks!
苏紫方璇 + 5 + 1 欢迎分析讨论交流,吾爱破解论坛有你更精彩!
hrh123 + 1 + 1 用心讨论,共获提升!

查看全部评分

本帖被以下淘专辑推荐:

发帖前要善用论坛搜索功能,那里可能会有你要找的答案或者已经有人发布过相同内容了,请勿重复发帖。

Hacking2heart 发表于 2023-9-23 10:18
学习一下。建议对输入加上一些点正则匹配处理,直接拼接到原生sql感觉不太安全。
amtf0614 发表于 2023-9-22 16:45
这种想法还是有点意思 我也研究下 哈哈  也是经常配合测试清数据
 楼主| 菲矾啊 发表于 2023-9-22 17:30
amtf0614 发表于 2023-9-22 16:45
这种想法还是有点意思 我也研究下 哈哈  也是经常配合测试清数据

偷懒使科技进步
wkdxz 发表于 2023-9-22 18:00
软件不错,谢谢楼主分享!
SriChen 发表于 2023-9-22 18:40
想法不错,期待成功
头像被屏蔽
moruye 发表于 2023-9-22 21:27
提示: 作者被禁止或删除 内容自动屏蔽
xuexiba 发表于 2023-9-22 23:09
思路不错,值得借鉴。
kkoo 发表于 2023-9-22 23:48
没有在开发环境搭一套数据库吗,有时候本地ip变动也经常连不上云数据库,挺头疼
wang11763 发表于 2023-9-23 04:40
这想法有意思
ShowJyu 发表于 2023-9-23 08:36
感谢分享
您需要登录后才可以回帖 登录 | 注册[Register]

本版积分规则 警告:本版块禁止灌水或回复与主题无关内容,违者重罚!

快速回复 收藏帖子 返回列表 搜索

RSS订阅|小黑屋|处罚记录|联系我们|吾爱破解 - LCG - LSG ( 京ICP备16042023号 | 京公网安备 11010502030087号 )

GMT+8, 2024-5-4 21:34

Powered by Discuz!

Copyright © 2001-2020, Tencent Cloud.

快速回复 返回顶部 返回列表