Advertisement
Guest User

Untitled

a guest
Jan 15th, 2019
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.18 KB | None | 0 0
  1. /// finaluri python fibonachi kompiqsebi
  2. def fibn(n):
  3. a, b = 0, 1
  4. for i in range(n):
  5. a, b = b, a+b
  6. return str(a)
  7.  
  8.  
  9. for i in range(1,10):
  10. print(fibn(i))
  11.  
  12.  
  13. ////////
  14.  
  15. /////////////////////finaluri PYTHON
  16.  
  17. # THIS IS PYTHONN !!!
  18. import mysql.connector
  19. from tkinter import *
  20. try:
  21. conn=mysql.connector.connect(user="root",password="",
  22. host="localhost",database="pythonTest")
  23. except Exception as ex:
  24. print(ex)
  25. else:
  26. root=Tk()
  27. root.title("my app")
  28. root.geometry("500x500")
  29.  
  30. label_one=Label(root,text="saxeli: ")
  31. label_one.place(x="100",y="100")
  32.  
  33. label_two=Label(root,text="gvari: ")
  34. label_two.place(x="100",y="120")
  35.  
  36.  
  37. label_three=Label(root,text="pm: ")
  38. label_three.place(x="100",y="140")
  39.  
  40. label_four = Label(root, text="fetch: ",wraplength=255)
  41. label_four.place(x="20", y="280")
  42.  
  43.  
  44.  
  45.  
  46. input_one=Entry(root)
  47. input_one.place(x="150",y="100")
  48. input_two=Entry(root)
  49. input_two.place(x="150",y="120")
  50. input_three=Entry(root)
  51. input_three.place(x="150",y="140")
  52.  
  53. def insert_records():
  54. mycursor=conn.cursor()
  55. sql="INSERT INTO python_user(fname,lname,pm)values(%s,%s,%s)"
  56. val=(input_one.get(),input_two.get(),input_three.get())
  57. mycursor.execute(sql,val)
  58. conn.commit()
  59.  
  60. input_one.delete(0,'end')
  61. input_two.delete(0,'end')
  62. input_three.delete(0,'end')
  63.  
  64. def fetch_records():
  65. mycursor1 = conn.cursor()
  66. mycursor1.execute("SELECT * FROM python_user")
  67. result = mycursor1.fetchall()
  68. for x in result :
  69. newText = (label_four.cget("text")+str(x)+" ")
  70. label_four.configure(text=newText)
  71.  
  72. #insert_records()
  73. btn1=Button(root,text="shenaxva")
  74. btn1.place(x="180",y="180")
  75. btn1.bind("<Button-1>",lambda event:insert_records())
  76.  
  77. #fetch_records()
  78. btn2 = Button(root,text="gamotana",fg="red",bg="white",activebackground="white",activeforeground="red")
  79. btn2.place(x="180", y="240")
  80. btn2.bind("<Button-1>", lambda event: fetch_records())
  81.  
  82.  
  83.  
  84.  
  85.  
  86. root.mainloop()
  87. finally:
  88. conn.close()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement