-


cursor.execute(“UPDATE employees SET name = ‘Tony’ WHERE id=1”)



Download 9,79 Mb.
Pdf ko'rish
bet62/64
Sana16.01.2022
Hajmi9,79 Mb.
#372467
1   ...   56   57   58   59   60   61   62   63   64
Bog'liq
[Nichola Lacey] Python by Example Learning to Pro(1)

cursor.execute(“UPDATE employees SET name = ‘Tony’ WHERE id=1”) 
db.commit() 
Updates the data in the table (overwriting the original data) to change the name to 
“Tony” for employee ID 1. 
cursor.execute(“DELETE employees WHERE id=1”) 


1140 
 
Challenges 139 - 145: SQLite 
 
 
Challenges 
 
 
139 
 
Create an SQL database called PhoneBook that 
contains a table called Names with the following data: 
140 
 
Using the PhoneBook 
database from program 139, 
write a program that will 
display the following menu. 
 
If the user selects 1, they 
should be able to view the 
entire phonebook. If they 
select 2, it should allow them 
to add a new person to the 
phonebook. If they select 3, it 
should ask them for a 
surname and then display 
only the records of people 
with the same surname. If 
they select 4, it should ask 
for an ID and then delete that 
record from the table. If they 
select 5, it should end the 
program. Finally, it should 
display a suitable message if 
they enter an incorrect 
selection from the menu. 
They should return to the 
menu after each action, until 
they select 5. 
141 
 
Create a new SQL database called BookInfo that will 
store a list of authors and the books they wrote. 
It will have two tables. The first one should be called 
Authors and contain the following data: 
 
 
The second should be called Books and contain the 
following data: 
 
142 
 
Using the BookInfo database from 
program 141, display the list of 
authors and their place of birth. Ask 
the user to enter a place of birth and 
then show the title, date published 
and author’s name for all the books 
by authors who were born in the 
location they selected. 
143 
 
Using the BookInfo database, ask the user to 
enter a year and display all the books 
published after that year, sorted by the year 
they were published. 


Challenges 139 - 145: SQLite 
1141 
 
 
 
 
 
 
 
 
 
 
 
 
 
144 
 
Using the BookInfo database, ask the user for an author’s name and then save all the 
books by that author to a text file, with each field separated by dashes so it looks as 
follows: 
 
Open the text file to make sure it has worked correctly. 
145 
 
Create a program that displays the following screen: 
 
 
It should save the data to an SQL database called 
TestScores when the Add button is clicked. The Clear 
button should clear the window. 
You have learnt so much. Look back 
on all the challenges and 
programming techniques you have 
learnt. It really is amazing.. 


1142 
 
Challenges 139 - 145: SQLite 
 
 
Answers 
1139 
 


Challenges 139 - 145: SQLite 
1143 
 
 
 
1140 
 


1144 
 
Challenges 139 - 145: SQLite 
 
 
1141 
 


Challenges 139 - 145: SQLite 
1145 
 
 
 
1142 
 
143 
 
144 
 


1146 
 
Challenges 139 - 145: SQLite 
 
 
1145 
 
 


 
 
 
 
 
Download 9,79 Mb.

Do'stlaringiz bilan baham:
1   ...   56   57   58   59   60   61   62   63   64




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©hozir.org 2024
ma'muriyatiga murojaat qiling

kiriting | ro'yxatdan o'tish
    Bosh sahifa
юртда тантана
Боғда битган
Бугун юртда
Эшитганлар жилманглар
Эшитмадим деманглар
битган бодомлар
Yangiariq tumani
qitish marakazi
Raqamli texnologiyalar
ilishida muhokamadan
tasdiqqa tavsiya
tavsiya etilgan
iqtisodiyot kafedrasi
steiermarkischen landesregierung
asarlaringizni yuboring
o'zingizning asarlaringizni
Iltimos faqat
faqat o'zingizning
steierm rkischen
landesregierung fachabteilung
rkischen landesregierung
hamshira loyihasi
loyihasi mavsum
faolyatining oqibatlari
asosiy adabiyotlar
fakulteti ahborot
ahborot havfsizligi
havfsizligi kafedrasi
fanidan bo’yicha
fakulteti iqtisodiyot
boshqaruv fakulteti
chiqarishda boshqaruv
ishlab chiqarishda
iqtisodiyot fakultet
multiservis tarmoqlari
fanidan asosiy
Uzbek fanidan
mavzulari potok
asosidagi multiservis
'aliyyil a'ziym
billahil 'aliyyil
illaa billahil
quvvata illaa
falah' deganida
Kompyuter savodxonligi
bo’yicha mustaqil
'alal falah'
Hayya 'alal
'alas soloh
Hayya 'alas
mavsum boyicha


yuklab olish