Advertisement
Guest User

Untitled

a guest
Nov 15th, 2019
321
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.98 KB | None | 0 0
  1. import sqlite3
  2. from employee import employee
  3.  
  4. def create_employee_table():
  5. connection = sqlite3.connect("employee.db")
  6.  
  7. connection_cursor = connection.cursor()
  8.  
  9. connection_cursor.execute("""CREATE TABLE IF NOT EXIST EMPLOYEE(
  10. id integer PRIMARY KEY AUTOINCREMENT,
  11. first_name text,
  12. last_name text,
  13. pay_roll integer
  14. )""")
  15. connection.commit()
  16. connection.close()
  17.  
  18. def create_employee():
  19. connection = sqlite3.connect("employee.db")
  20. connection_cursor = connection.cursor()
  21. connection_cursor.execute("""INSERT INTO employees VALUES (first_name text, last_name text, pay_roll)
  22. VALUES ('Vytautas', 'Ragaisis', '7000')""")
  23. connection.commit()
  24. connection.close()
  25.  
  26.  
  27. create_employee()
  28.  
  29. def select_employee_table():
  30. connection = sqlite3.connect("employee.db")
  31. connection_cursor = connection.cursor()
  32. connection_cursor.execute("""SELECT * FROM EMPLOYEE
  33. """)
  34. connection.commit()
  35. connection.close()
  36.  
  37. def update_employee():
  38. connection = sqlite3.connect("employee.db")
  39. connection_cursor = connection.cursor()
  40. connection_cursor.execute("""UPDATE FROM EMPLOYEE,
  41. SET first_name = 'Vytautas',
  42. SET last_name = 'Ragaisis'
  43. """)
  44. connection.commit()
  45. connection.close()
  46.  
  47. def delete_employee():
  48. connection = sqlite3.connect("employee.db")
  49. connection_cursor = connection.cursor()
  50. connection_cursor.execute("""DELETE FROM EMPLOYEE,
  51. WHERE 'Vytautas'
  52. """)
  53. connection.commit()
  54.  
  55. connection.close()
  56.  
  57. delete_employee()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement