Guest User

Untitled

a guest
May 5th, 2018
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.70 KB | None | 0 0
  1. import sqlite3
  2.  
  3. conn = sqlite3.connect('example.db')
  4.  
  5. c = conn.cursor()
  6.  
  7. create_users = 'CREATE TABLE IF NOT EXISTS users (id INTEGER PRIMARY KEY AUTOINCREMENT, login VARCHAR(200), password VARCHAR(200))'
  8.  
  9. c.execute(create_users)
  10. conn.commit()
  11.  
  12. a = raw_input("Please type your login and password \n")
  13.  
  14. login, password = a.split()
  15.  
  16. # insert_user = 'INSERT INTO users (login,password) VALUES("{}","{}")'.format(login,password)
  17.  
  18.  
  19. # c.execute(insert_user)
  20. # conn.commit()
  21.  
  22.  
  23. get_user = 'SELECT * from users WHERE login = "{}" AND password = "{}"'.format(login,password)
  24.  
  25. c.execute(get_user)
  26.  
  27. user = c.fetchone()
  28.  
  29.  
  30. if user is None:
  31. print("NO DATA FOR YOU, LOOSER")
  32. else:
  33. print("Hello, " + user[1])
  34.  
  35. conn.close()
Add Comment
Please, Sign In to add comment