Advertisement
Guest User

Untitled

a guest
Feb 17th, 2020
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.95 KB | None | 0 0
  1.  
  2. import sqlite3, random
  3. conn = sqlite3.connect("my_database.db")
  4. cursor = conn.cursor()
  5. try:
  6. cursor.execute("""CREATE TABLE cotrud
  7. (id integer, name text, is_work text, date_birst text, professia text)
  8. """)
  9. except Exception:
  10. pass
  11.  
  12. def ad():
  13. name = input()
  14. is_work = input()
  15. date_birst = input()
  16. professia = input()
  17. cursor.execute(f"""INSERT INTO cotrud
  18. VALUES ({random.randint(1,1000000000)}, '{name}', '{is_work}', '{date_birst}', '{professia}')"""
  19. )
  20. conn.commit()
  21.  
  22. def dell():
  23. sql = f"DELETE FROM cotrud WHERE id = {int(input())}"
  24. cursor.execute(sql)
  25. conn.commit()
  26.  
  27. def reed():
  28. sql = "SELECT * FROM cotrud"
  29. cursor.execute(sql)
  30. print(cursor.fetchall())
  31.  
  32. def sorterow():
  33. name = input()
  34. sql = f"SELECT * FROM cotrud ORDER BY {name}"
  35. cursor.execute(sql)
  36. print(cursor.fetchall())
  37.  
  38. breakpoint()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement