Advertisement
Guest User

python sqlite3 inset data tkiner

a guest
Aug 21st, 2018
131
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.91 KB | None | 0 0
  1. from Tkinter import *
  2. import subprocess
  3. import sqlite3
  4. class Start():
  5.     def __init__(self):
  6.         self.root = Tk()
  7.         self.root.geometry("300x200")
  8.         self.leb = Label(self.root, text="username:")
  9.         self.leb.place(x=20,y=20)
  10.         self.net = Label(self.root, text="password:")
  11.         self.net.place(x=20,y=40)
  12.         self.ley = Entry(self.root,)
  13.         self.ley.place(x=80,y=25)
  14.         self.ley2 = Entry(self.root, show="*")
  15.         self.ley2.place(x=80, y=45)
  16.         self.butt = Button(self.root, text="login")
  17.         self.butt.place(x=165,y=95)
  18.         self.butt2 = Button(self.root, text="registration", command=self.registration)
  19.         self.butt2.place(x=15, y=95)
  20.         mainloop()
  21.  
  22.     def registration(self):
  23.         self.root2= Tk()
  24.         self.root2.geometry("400x200")
  25.         self.eny3 = Label(self.root2, text="first name")
  26.         self.eny3.place(x=20,y=20)
  27.         self.eny3 = Label(self.root2, text="lest name")
  28.         self.eny3.place(x=20, y=40)
  29.         self.eny3 = Label(self.root2, text="email")
  30.         self.eny3.place(x=20, y=60)
  31.         self.eny3 = Label(self.root2, text="password")
  32.         self.eny3.place(x=20, y=80)
  33.         self.eny3 = Label(self.root2, text="second password")
  34.         self.eny3.place(x=20, y=100)
  35.         self.br1 = Entry(self.root2)
  36.         self.br1.place(x=80,y=20)
  37.         self.br2 = Entry(self.root2)
  38.         self.br2.place(x=80,y=40)
  39.         self.br3 = Entry(self.root2)
  40.         self.br3.place(x=80,y=60)
  41.         self.br4 = Entry(self.root2, show="*")
  42.         self.br4.place(x=80,y=80)
  43.         self.br5 = Entry(self.root2, show="*")
  44.         self.br5.place(x=120, y=100)
  45.         self.butt3 = Button(self.root2, text="register", command=self.checksocket)
  46.         self.butt3.place(x=195,y=150)
  47.  
  48.  
  49.     def checksocket(self):
  50.         firstname=  self.br1.get()
  51.         lesttname = self.br2.get()
  52.         email = self.br3.get()
  53.         password = self.br4.get()
  54.         password2 = self.br5.get()
  55.         conn = sqlite3.connect("myweb.db")
  56.         c = conn.cursor()
  57.         names1 = [self.br1.get(),self.br2.get(),self.br3.get(),self.br4.get(),self.br5.get()]
  58.  
  59.         c.execute('''create table if not exists michael2(id integer primary key autoincrement,   firstname varchar(100),lestname varchar(200), email varchar(200),password varchar(200),scuondpasssowrd varchar(200))''')
  60.  
  61.  
  62.  
  63.         for inv in names1:
  64.             c.execute("insert into michael2(firstname,lestname,email)  values (?,?,?)"),(firstname,lesttname,email)
  65.  
  66.  
  67.  
  68.  
  69.         sql = "select * from michael"
  70.         c.execute(sql)
  71.         ssss =c.fetchall()
  72.         for o in ssss:
  73.             print o
  74.         #for i1 in names1:
  75.          #  c.execute("insert into username(id,username,password) values(NULL,?,?,?,?,?)",[i1])
  76.         #for n in c.execute("SELECT * FROM tasks"):
  77.          #   print n
  78.  
  79.         conn.commit()
  80.  
  81. f = Start()
  82.  
  83.  
  84. def main():
  85.     f
  86.  
  87. main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement