Advertisement
xavicano

Untitled

May 17th, 2020
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.63 KB | None | 0 0
  1. import sqlite3
  2. conn = sqlite3.connect("computer_cards.db")
  3.  
  4. def create(name, cores,cpu_speed, ram, cost):
  5.     insert_sql = "INSERT INTO computer(name, cores, cpu_speed, ram, cost) VALUES ('{}',{},{},{},{})".format(name, cores, cpu_speed, ram, cost)
  6.     conn.execute(insert_sql)
  7.     conn.commit()
  8.  
  9. print("Enter the details:")
  10.  
  11. name = input("Name > ")
  12. cores = input("Cores > ")
  13. cpu_speed= float(input("CPU Speed in GHz> "))
  14. ram= input("RAM in GB > ")
  15. cost= input("Cost in € > ")
  16.  
  17. create(name, cores,cpu_speed, ram, cost)
  18.  
  19. result = conn.execute("SELECT * FROM computer")
  20. computers = result.fetchall()
  21.  
  22. for computer in computers:
  23.     print(computer)
  24.  
  25. conn.close()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement