Listing 11 - Page 0: No Title

##############################################################################
# Python From Scratch
# Autor: Nilo Ney Coutinho Menezes
# Editora Novatec (c) 2010-2024
# Site: https://pythonfromscratch.com
#
# File: listing\chapter 11\11.1484 - No Title.py
# Description: No Title
##############################################################################

import sqlite3
from contextlib import closing

with sqlite3.connect("phonebook.db") as connection:
    connection.row_factory = sqlite3.Row
    with closing(connection.cursor()) as cursor:
        for record in cursor.execute("select * from phonebook"):
            print(f"Name: {record['name']}\nPhone: {record['phone']}")
Click here to download the file