Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started