File tree Expand file tree Collapse file tree 3 files changed +13
-4
lines changed
Expand file tree Collapse file tree 3 files changed +13
-4
lines changed Original file line number Diff line number Diff line change 22
33conn = sqlite3 .connect ("contacts.sqlite" )
44
5- for row in conn .execute ("SELECT * FROM contacts" ):
5+ name = input ("Please enter a name to search for: " )
6+
7+ for row in conn .execute ("SELECT * FROM contacts WHERE name = ?" , (name ,)):
68 print (row )
79
810conn .close ()
Original file line number Diff line number Diff line change 22
33db = sqlite3 .connect ("contacts.sqlite" )
44
5- update_sql = "UPDATE contacts SET email = 'update@update.com' WHERE contacts.phone = 1234"
5+ new_email = "another.update@update.com"
6+ phone = input ("Please enter the phone number: " )
7+
8+ # update_sql = f"UPDATE contacts SET email = {new_email} WHERE contacts.phone = {phone}"
9+ update_sql = f"UPDATE contacts SET email = ? WHERE contacts.phone = ?"
10+ print (update_sql )
11+
612update_cursor = db .cursor ()
7- update_cursor .execute (update_sql )
8- print (f"{ update_cursor .rowcount } rows updated" )
13+ update_cursor .execute (update_sql , (new_email , phone ))
14+ # update_cursor.executescript(update_sql)
15+ # print(f"{update_cursor.rowcount} rows updated")
916
1017update_cursor .connection .commit ()
1118update_cursor .close ()
You can’t perform that action at this time.
0 commit comments