为什么我在python 3

时间:2019-08-09 17:34:33

标签: sql python-3.x tkinter

我正在使用tkinter和python制作gui,在项目中我想插入和更新数据库,但是在输入值后我得到了这个警告,并且我的数据库没有更新

    name=username.get()
    acc=ask.get()
    pi=val.get()
    am=nw.get()

    conn = connect(host="localhost",user="root",password="",db='atm')
    var = conn.cursor()
    var.execute("select * from account_detail where 
    account_no='"+acc+"'and pin='"+pi+"' ")
    row=var.rowcount
    if(row>0):
        var.execute("update account_detail set amount=amount+'"+am+"' 
        where account='"+acc+"' ")
        var.execute("insert into mini (account_no,pin,username,balance) 
        values ('"+acc+"','"+pi+"','"+name+"','"+am+"' ) ")
        conn.commit()
        messagebox.showinfo("Information","deposited  successfully")
    else:
        messagebox.showinfo("Information","not valid")
        conn.rollback()
        messagebox.showinfo("Information","Data Transfer Failed")

updatebtn=Button(upwin,text="deposit",font="Times 10",relief=RAISED,bd=8,command=depo,width=20).place(x=130,y=230)

遇到此错误

警告(来自警告模块):文件“ C:\ Users \ a \ AppData \ Local \ Programs \ Python \ Python37-32 \ lib \ site-packages \ pymysql \ cursors.py”,第170行     结果= self._query(查询) 警告:(1292,“截断了不正确的DOUBLE值:””)

1 个答案:

答案 0 :(得分:0)

尝试在求和运算之前验证金额值。

update account_detail set amount= isnull(amount,0) + '"+am+"'