如何使用带有GUI用户输入的Python3.6更新数据库中的数据。。。。?

2024-06-25 23:17:17 发布

您现在位置:Python中文网/ 问答频道 /正文

这是我的代码,但我得到一个错误,说args没有定义。 我想知道如何从数据库和GUI中的用户访问数据。你知道吗

def f6():

    upst.deiconify()
    root.withdraw()
    import cx_Oracle
    con=None
    cursor=None
    try:

        con=cx_Oracle.connect("system/abc123")
        cursor=con.cursor()
        sql="update student set name='%s' where rno='%d'"
        args(name,rno)
        cursor.execute(sql % args)
        con.commit()
        msg=str(cursor.rowcount)+"row updated"
        messagebox.showinfo("Record updated",msg)

    except cx_Oracle.DatabaseError as e:
        if con is not None:
            con.rollback()
        messagebox.showerror("Failure",e)

    finally:
        cursor.close()
        if con is not None:
            con.close()

btnUpdate=Button(root,text="Update",width=10,command=f6)

Tags: namenonesqlifargsmsgrootcon