Listing 11-06: Example of update without where and with rowcount

##############################################################################
# Python From Scratch
# Autor: Nilo Ney Coutinho Menezes
# Editora Novatec (c) 2010-2024
# Site: https://pythonfromscratch.com
#
# File: listing\chapter 11\11.06 - Example of update without where and with rowcount.py
# Description: Example of update without where and with rowcount
##############################################################################

import sqlite3
from contextlib import closing

with sqlite3.connect("phonebook.db") as connection:
    with closing(connection.cursor()) as cursor:
        cursor.execute("""update phonebook
                             set telephone = '12345-6789' """)
        print("Updated records: ", cursor.rowcount)
Click here to download the file