Advertisement
brendan-stanford

sql_card-game

Jan 30th, 2020
132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.67 KB | None | 0 0
  1. #import libraries
  2. import sqlite3
  3.  
  4. #connect to database
  5. conn = sqlite3.connect("computer_cards.db")
  6.  
  7. #define computer data creation function
  8. def create(name, cores, cpu_speed, ram, cost):
  9. insert_sql = "INSERT INTO computer(name, cores, cpu_speed, ram, cost) VALUES ('{}', {}, {}, {}, {})".format(name, cores, cpu_speed, ram, cost)
  10. conn.execute(insert_sql)
  11. conn.commit()
  12.  
  13. #collect new compouter details
  14. print("Enter new details:")
  15. name = input("Name > ")
  16. cores = input("Cores > ")
  17. cpu_speed = input("CPU speed > ")
  18. ram = input("RAM > ")
  19. cost = input("Cost > ")
  20.  
  21. #create new computer according to input values
  22. create(name, cores, cpu_speed, ram, cost)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement