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.
$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()
Comments
Leave a comment