Question: import sqlite 3 conn = sqlite 3 . connect ( test . db ) print ( Database connected. ) conn.execute ( '
import sqlite
conn sqliteconnecttestdb
printDatabase connected."
conn.executeCREATE TABLE IF NOT EXISTS CONTACTS
ID INT PRIMARY KEY NOT NULL,
NAME TEXT NOT NULL,
AGE INT NOT NULL,
ADDRESS CHAR;
printTable created."
conn.executeINSERT INTO CONTACTS IDNAME,AGE,ADDRESS
VALUES 'Polly', 'Seattle';
conn.executeINSERT INTO CONTACTS IDNAME,AGE,ADDRESS
VALUES 'Roger', 'Bainbridge';
conn.commit
printRecords created."
cursor conn.executeSELECT from CONTACTS"
for row in cursor:
print ID strrow
print NAME row
printAGE strrow
print ADDRESS strrow
print Records found."
cursor conn.executeUPDATE CONTACTS SET NAME 'Mazen' WHERE NAME 'Polly'"
conn.commit
cursor conn.executeSELECT from CONTACTS"
for row in cursor:
print ID strrow
print NAME row
printAGE strrow
print ADDRESS strrow
printRecords updated."
cursor conn.executeDELETE FROM CONTACTS WHERE NAME 'Polly'"
conn.commit
printRecord deieted"
conn.close
Use this code to:
Create a Python script for managing a server.
Create a Python module to consume data from a public API and reformat the data to present as a web page.
Create a Python module for complex queries to a SQL or NoSQL database.
Create a Python module to search log files for selected content and to generate a report on what is discovered.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
