Mori007

insert new database

Feb 24th, 2021
664
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. # Chalanges insert new data
  2.  
  3. import sqlite3
  4.  
  5.  
  6. # Function to insert data to database
  7. def create(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. # Making connection to database
  13. conn = sqlite3.connect("d:/Pystrukturdata/databasenya/computer_cards.db")
  14.  
  15. # Making input data
  16. print("Enter the details:")
  17. name = input("Name > ")
  18. cores = input("Cores > ")
  19. cpu_speed = input("CPU Speed > ")
  20. ram = input("Total RAM > ")
  21. cost = input("Cost Computer-$- > ")
  22.  
  23. # Call the function
  24. create(name, cores, cpu_speed, ram, cost)
  25.  
  26. # CLosing connection the database
  27. conn.close()
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×