Answer to Question #207556 in Python for dhrsn

Question #207556

1. Create a SQLite database for Places‐of‐Interests (POI) 2. Apply the CRUD concept using Python‘s function (def) 3. Test each of your CRUD functions with the following use case: a. Create the appropriate table with it‘s table structure,  b. Populate 20 POIs into the table c. Get the latest row in the table d. Retrieve all POI data e. Update several POI data f. Delete two POI records g. Undo the deletion record proces


1
Expert's answer
2021-06-16T15:39:49-0400
1.
 $sqlite3 poi.db


import sqlite3

db=sqlite3.connect('poi.db')

try:     

  c =db.cursor()

  c.execute('''CREATE TABLE details (

  ID INTEGER PRIMARY KEY AUTOINCREMENT,

  name TEXT (20) NOT NULL,

  age INTEGER);''')

except:

  print ('error in operation')

  db.rollback()

db.close()


import sqlite3
db=sqlite3.connect('poi.db')
qwry="insert into details (name, age) values('John', 20);"
try:
    c=db.cursor()
    c.execute(qry)
    db.commit()
except:
    print ("error in operation")
    db.rollback()
db.close()




Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS