fork download
  1. #!/usr/bin/python
  2. # -*- coding: utf-8 -*-
  3. from Tkinter import *
  4. import MySQLdb
  5.  
  6. def tran():
  7. first = Tk()
  8. label1 = Label(first, text='From')
  9. label1.pack()
  10. box1 = Entry(first)
  11. box1.pack()
  12. label2 = Label(first, text='To')
  13. label2.pack()
  14. box2 = Entry(first)
  15. box2.pack()
  16. label3 = Label(first, text='Amt')
  17. label3.pack()
  18. box3 = Entry(first)
  19. box3.pack()
  20. Button1 = Button(first, text='Next', command=func3).pack()
  21.  
  22. def func3():
  23. conn = MySQLdb.connect(host='localhost', user='root', passwd='natty'
  24. , db='dbms')
  25. cursor = conn.cursor()
  26. From = int(box1.get().strip())
  27. To = int(box2.get().strip())
  28. Amt = int(box3.get().strip())
  29. cursor.execute('select bal from account where acc=' + str(From) + ''
  30. )
  31. a = cursor.fetchone()
  32. fromval = int(a[0])
  33. cursor.execute('select bal from account where acc=' + str(To) + '')
  34. b = cursor.fetchone()
  35. toval = int(b[0])
  36. fromval = fromval - Amt
  37. toval = toval + Amt
  38. cursor.execute('update account set bal=' + str(fromval)
  39. + ' where acc=' + str(From) + '')
  40. cursor.execute('update account set bal=' + str(toval)
  41. + ' where acc=' + str(To) + '')
  42. cursor.close()
  43. conn.close()
  44.  
  45. master = Tk()
  46. Button3 = Button(master, text='Transaction', command=tran).pack()
  47. mainloop()
  48.  
Not running #stdin #stdout 0s 0KB
stdin
Standard input is empty
stdout

Standard output is empty