Advertisement
timber101

AddNewDataTOSQLiteDatabase

Jan 14th, 2021
743
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.64 KB | None | 0 0
  1. # adding new data to database
  2. import sqlite3 # get the module
  3.  
  4. conn = sqlite3.connect("computer_cards.db") #connect to the databse
  5.  
  6. #function to add new cards
  7. def addnew(name, cores, cpu_speed, ram, cost):
  8.     insert_sql = "insert into computer(name, cores, cpu_speed, ram, cost) values ('{}', {}, {}, {}, {})".format(name, cores, cpu_speed, ram, cost)
  9.     conn.execute(insert_sql)
  10.     conn.commit()
  11.  
  12. print("Add a new card")
  13.  
  14. entname = input("Name >> ")
  15. entcores = input("Cores >> ")
  16. entcpu_speed = input("CPU speed >> ")
  17. entram = input ("RAM >> ")
  18. entcost = input ("Cost >> ")
  19.    
  20. addnew(entname, entcores, entcpu_speed, entram, entcost)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement