Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #import libraries
- import sqlite3
- #connect to database
- conn = sqlite3.connect("computer_cards.db")
- #define computer data creation function
- def create(name, cores, cpu_speed, ram, cost):
- insert_sql = "INSERT INTO computer(name, cores, cpu_speed, ram, cost) VALUES ('{}', {}, {}, {}, {})".format(name, cores, cpu_speed, ram, cost)
- conn.execute(insert_sql)
- conn.commit()
- #collect new compouter details
- print("Enter new details:")
- name = input("Name > ")
- cores = input("Cores > ")
- cpu_speed = input("CPU speed > ")
- ram = input("RAM > ")
- cost = input("Cost > ")
- #create new computer according to input values
- create(name, cores, cpu_speed, ram, cost)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement