0% found this document useful (0 votes)
111 views28 pages

Contact Book Project

This document provides an overview of a digital clock project that aims to design and implement a digital clock using a microcontroller and other electronic components. The clock will display the time in hours, minutes and seconds using LEDs, LCD or other digital displays. It will keep accurate time through the use of a real-time clock module or by synchronizing with an external time source. The project offers an educational opportunity to learn about microcontrollers, electronics, and timekeeping principles. It also provides a practical application of embedded systems. The document outlines the project requirements, feasibility study, system architecture, component selection, software development and testing process.

Uploaded by

sp2392546
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
111 views28 pages

Contact Book Project

This document provides an overview of a digital clock project that aims to design and implement a digital clock using a microcontroller and other electronic components. The clock will display the time in hours, minutes and seconds using LEDs, LCD or other digital displays. It will keep accurate time through the use of a real-time clock module or by synchronizing with an external time source. The project offers an educational opportunity to learn about microcontrollers, electronics, and timekeeping principles. It also provides a practical application of embedded systems. The document outlines the project requirements, feasibility study, system architecture, component selection, software development and testing process.

Uploaded by

sp2392546
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 28

Contact Book – DIGITAL CLOCK

A Project Work submitted in partial fulfillment of the


requirements for the degree of
Bachelor of Computer Application
To the
Periyar University,Salem-11
By
SUNDARESAN K
C21UG105CAP025

GOVERNMENT ARTS COLLEGE-105


(AFFILIATED TO PERIYAR UNIVERSITY)
Dharmapuri-6363701
MARCH-2024
Abstract

This project aims to design and implement a digital clock using basic electronic components and microcontroller
technology. The digital clock will display time in hours, minutes, and seconds using LEDs or a digital display. The clock
will be capable of accurately keeping time and may include additional features such as alarm functionality,
temperature display, and adjustable brightness.

The project will utilize a microcontroller such as Arduino or Raspberry Pi to control the clock’s operations.
Timekeeping accuracy will be ensured through the use of real-time clock (RTC) modules or by synchronizing with an
external time source such as a GPS module or internet time server.

The digital clock project offers an educational opportunity to learn about microcontroller programming, electronic
circuit design, and timekeeping principles. It also provides a practical application of embedded systems in everyday
devices. Additionally, the project can be expanded upon to include additional features or customized to suit specific
requirements.
Table Of Content

Chapter One :-
Acknowledgements…………………………………………….
1.1-Introduction………………………………………………...
1.2-Over View……………………………………………….
1.3- System Specification………………………………………
1. Hardware………………………………………..
2. Software…………………………………………….

Chapter two :-
2. System Study……………………………………….
2.1- Exiting System………………………………….
1.Description………………………………..
2.Draw Backs………………………………….
2.2- Propose System……………………………………..
1.Description…………………………………
2.Features……………………………………

Chapter Three:-
3. Software Design System……………………………….
3.1- Input Design…………………………………………
3.2- Output Design…………………………………………
3.3- Code Design…………………………………………..
3.4- Modules………………………………………………..
Chapter four:-
4. System Informations…………………………………….

Chapter five:-
5.Conclusion……………………………………….

Chapter six:-
6. References…………………………………

Chapter seven:-
7. Source Code………………………………………..

Chapter eight:-
8. Screen Layout………………………………………….
Acknowledgements:

We would like to express our sincere gratitude to all those who have contributed to the successful completion of this
digital clock project.

First and foremost, we extend our deepest appreciation to our project supervisor [Supervisor’s Name] for their
invaluable guidance, support, and encouragement throughout the duration of this project. Their expertise and
insights have been instrumental in shaping our ideas and refining our approach.

We would also like to thank our teachers and mentors for their constant encouragement and for providing us with
the necessary resources and facilities to undertake this project.

Our heartfelt thanks go to our fellow classmates and friends for their constructive feedback, discussions, and moral
support, which have greatly contributed to the development of this project.
CHAPTER 1
1.INTRODUCTION
In an era dominated by digital technology, the humble clock continues to play a vital role in our daily lives, serving as
a constant reminder of the passage of time. With the advancement of electronics and microcontroller technology,
the traditional mechanical clocks have given way to sleek and precise digital timepieces.

This project introduces the design and implementation of a digital clock, a quintessential example of the fusion
between hardware and software engineering. The digital clock serves not only as a practical timekeeping device but
also as an educational platform for enthusiasts and aspiring engineers to delve into the realm of embedded systems.

The primary objective of this project is to construct a digital clock capable of accurately displaying time in hours,
minutes, and seconds using LEDs, LCD, or 7-segment displays. Beyond mere timekeeping, the clock may incorporate
additional features such as alarm functionality, temperature display, and adjustable brightness, thereby enhancing
its utility and versatility.

Project Overview:-

In an era dominated by digital technology, the humble clock continues to play a vital role in our daily lives, serving as
a constant reminder of the passage of time. With the advancement of electronics and microcontroller technology,
the traditional mechanical clocks have given way to sleek and precise digital timepieces.
This project introduces the design and implementation of a digital clock, a quintessential example of the fusion
between hardware and software engineering. The digital clock serves not only as a practical timekeeping device but
also as an educational platform for enthusiasts and aspiring engineers to delve into the realm of embedded systems.

The primary objective of this project is to construct a digital clock capable of accurately displaying time in hours,
minutes, and seconds using LEDs, LCD, or 7-segment displays. Beyond mere timekeeping, the clock may incorporate
additional features such as alarm functionality, temperature display, and adjustable brightness, thereby enhancing
its utility and versatility.

System Specification:-
1. Hardware Requirements:
Processor: Dual-core processor or higher
RAM: 2 GB or higher
Storage: At least 100 MB of free disk space
Display: Monitor with a resolution of 1024x768 pixels or higher
Input Devices: Keyboard, Mouse (for desktop applications).
2. Software Requirements:
Operating System: Windows 7 or later, macOS, Linux
Python: Version 3.6 or higher
MySQL: Version 5.7 or higher
mysql-connector-python: Latest version
IDE or Text Editor: Any IDE or text editor of choice (e.g., Visual Studio Code, PyCharm, Sublime
Text)
MySQL Workbench (Optional): For database administration and management.

CHAPTER 2
SYSTEM SYUDY
1. **Requirements Analysis**: Identify the functional and non-functional requirements of the digital clock,
such as displaying time accurately, setting alarms, adjusting brightness, and ensuring reliability.

2. **Feasibility Study**: Assess the technical, economic, and operational feasibility of the project, considering
factors such as available components, budget constraints, and project timeline.

3. **System Architecture**: Define the overall architecture of the digital clock system, including the
microcontroller, real-time clock module, display unit, input controls, and power supply. Determine how
these components will interact to fulfill the system requirements.

4. **Microcontroller Selection**: Evaluate different microcontroller options (e.g., Arduino, Raspberry Pi) based
on factors like processing power, memory, and available libraries. Choose the most suitable microcontroller
for the project requirements.

5. **Real-Time Clock Module Integration**: Select and integrate a real-time clock module to ensure accurate
timekeeping. Determine whether to use an external time source (e.g., GPS module, internet time server) or
rely on an onboard clock chip.

6. **Display Unit Design**: Choose the display technology (e.g., LEDs, LCD, 7-segment displays) based on
factors like readability, power consumption, and cost. Design the circuitry and interface to drive the chosen
display unit.

7. **Input Control Mechanism**: Design and implement input controls (e.g., buttons, switches) for setting
time, alarms, and adjusting settings. Develop the user interface logic to handle user inputs and update the
clock settings accordingly.

8. **Power Supply Management**: Design a stable power supply system to ensure continuous operation of the
digital clock. Consider factors like voltage regulation, power efficiency, and battery backup options if
necessary.

9. **Software Development**: Write the firmware or software code to control the digital clock’s operation.
Implement functions for timekeeping, alarm management, display control, and user interaction.

10. **Testing and Validation**: Conduct thorough testing of the digital clock system to ensure that it meets the
specified requirements. Test for functionality, accuracy, reliability, and user interface usability.
11. **Documentation and User Manual**: Prepare comprehensive documentation detailing the design,
implementation, and operation of the digital clock. Create a user manual to guide users in setting up and
using the clock effectively.

12. **Maintenance and Support**: Establish procedures for maintaining and supporting the digital clock system
post-deployment. Provide resources and assistance to troubleshoot issues and address user inquiries.

EXISTING SYSTEM:-
Digital Clocks – Basic: Basic digital clocks use digital displays, such as LEDs or LCDs, to show time numerically in hours,
minutes, and sometimes seconds. These clocks often rely on quartz crystal oscillators for timekeeping accuracy

1.Description:
The digital clock project involves the design and construction of a modern timekeeping device using
electronic components and microcontroller technology. The digital clock will display time numerically in
hours, minutes, and seconds, providing accurate timekeeping functionality.

2.Draw Backs:
digital clock projects remain popular among electronics enthusiasts and hobbyists as a rewarding way to
learn about embedded systems, programming, and timekeeping technology. With careful planning and attention to
detail, many of these challenges can be overcome to create a functional and reliable digital clock

PROPOSED SYSTEM:-
The proposed Contact Book System aims to address the limitations of traditional contact management
methods by offering a modern, user-friendly, and feature-rich solution. Here's an outline of the proposed
system:

1. Description:

The digital clock project involves the design and construction of a modern timekeeping device using
electronic components and microcontroller technology. The digital clock will display time numerically in
hours, minutes, and seconds, providing accurate timekeeping functionality

2. Key Features:

Features of the Digital Clock Project:


1. **Accurate Timekeeping**: The digital clock will accurately display time in hours, minutes, and seconds,
ensuring reliable timekeeping functionality.

2. **Adjustable Brightness**: Users can adjust the brightness of the display to suit their preferences and
ambient lighting conditions, enhancing readability and energy efficiency.

3. **Alarm Functionality**: The digital clock will include alarm functionality, allowing users to set multiple
alarms at specific times and customize alarm tones.

4. **Snooze Function**: Users can activate a snooze function to temporarily silence alarms and receive
reminders at preset intervals.

5. **Temperature Display (Optional)**: An optional feature to display ambient temperature alongside the
time, providing additional utility and convenience.

6. **User-Friendly Interface**: The digital clock will feature an intuitive user interface with easy-to-use input
controls for setting time, alarms, and adjusting settings.

7. **Customizable Display Formats**: Users can customize display formats, font styles, and colors to
personalize the appearance of the digital clock.

8. **Power Saving Mode**: The digital clock will include a power-saving mode to conserve energy when the
clock is not in use, extending battery life or reducing electricity consumption.

9. **Automatic Time Adjustment**: The clock may synchronize with an external time source such as an
internet time server or radio signals to automatically adjust for daylight saving time changes or maintain
precise timekeeping.

10. **Modular Design**: The digital clock system will be designed with a modular architecture, allowing for
easy expansion or modification of features such as adding additional sensors or connectivity options.

11. **Backup Battery (Optional)**: An optional backup battery system may be included to maintain
timekeeping functionality in the event of a power outage.
12. **Smart Connectivity (Optional)**: Integration with smart home systems or mobile devices for remote
control, synchronization with calendar events, or receiving weather updates.

These features collectively aim to create a versatile and user-friendly digital clock that meets the diverse needs
and preferences of users while offering enhanced functionality and convenience.

CHAPTER 3

SOFTWARE DESIGN SYSTEM


1. **Microcontroller Platform Selection**: Choose a suitable microcontroller platform (e.g., Arduino,
Raspberry Pi) based on project requirements, processing power, and available resources.

2. **Development Environment Setup**: Install and configure the necessary software development tools,
such as Arduino IDE or Raspberry Pi development environment, to write, compile, and upload firmware
code to the microcontroller.

3. **Firmware Architecture Design**:

- Define the overall architecture of the firmware, including modules for timekeeping, display control, input
handling, and alarm management.

- Determine the data structures and variables required to store time, alarm settings, display configurations, and
user inputs.

4. **Timekeeping Module**:

- Implement functions to initialize and update the real-time clock (RTC) module.

- Develop routines to read time data from the RTC module and update the internal clock variables accordingly.

- Ensure accurate timekeeping by handling time synchronization and adjustments as needed.

5. **Display Control Module**:

- Design functions to control the display unit, including turning on/off segments, updating digit values, and
adjusting brightness levels.

- Implement algorithms to convert time data into displayable formats (e.g., converting hours, minutes, and
seconds into segmented display patterns).

6. **Input Handling Module**:

- Define functions to read input from buttons, switches, or a touchscreen interface.

- Develop logic to interpret user inputs, such as setting time, configuring alarms, and adjusting settings.

- Implement debouncing techniques to ensure reliable input detection and prevent false triggers.
7. **Alarm Management Module**:

- Create functions to set, update, and disable alarms based on user inputs.

- Implement logic to trigger alarms at specified times, play alarm tones, and handle snooze functionality.

- Design algorithms to manage multiple alarms simultaneously and handle recurring alarm schedules.

8. **User Interface Design**:

- Develop a user-friendly interface to interact with the digital clock, displaying current time, alarm settings, and
configuration options.

- Design menus, prompts, and feedback mechanisms to guide users in setting up and using the clock effectively.

9. **Error Handling and Debugging**:

- Implement error handling mechanisms to detect and recover from software errors, such as communication
failures with the RTC module or input validation errors.

- Include debugging features, such as serial output messages or LED indicators, to aid in diagnosing software
issues during development and testing.

10. **Testing and Validation**:

- Conduct thorough testing of the firmware code to ensure functionality, accuracy, reliability, and usability.

1. Input Desing:-

1. **Input Devices Selection**: Choose appropriate input devices such as buttons, switches, or a touchscreen
interface based on user interaction requirements, ease of use, and available hardware resources.

2. **Button Layout Design**: Design the layout and arrangement of buttons to facilitate intuitive navigation
and operation. Consider ergonomic factors such as button size, spacing, and labeling for easy identification
and manipulation.

3. **Function Mapping**: Assign specific functions to each input device, defining their roles in setting time,
configuring alarms, adjusting settings, and navigating menu options. Map out the interaction flow to
ensure logical and intuitive user interactions.

4. **Input Handling Logic**:

- Implement firmware logic to detect and debounce input signals to prevent false triggers or multiple inputs from
a single action.
- Develop routines to interpret user inputs and trigger corresponding actions, such as
incrementing/decrementing time values, toggling alarm settings, or navigating menu options.

5. **User Feedback Mechanisms**:

- Provide visual and auditory feedback to confirm user actions and indicate system responses.

- Use LEDs, LCD displays, or buzzer tones to acknowledge button presses, highlight selected options, or indicate
error conditions (e.g., invalid input).

6. **Button Long-Press Actions**: Implement long-press functionality for buttons to trigger alternate actions or
enter configuration modes. Define thresholds for detecting long-press events and differentiate them from short
presses.

7. **Error Handling**:

- Include error detection and validation mechanisms to handle invalid inputs or out-of-range values.

- Provide informative error messages or feedback to guide users in correcting input errors and prevent confusion.

8. **User Interface Integration**:

- Integrate input devices seamlessly with the user interface, ensuring consistent interaction patterns and
responsiveness.

- Design the user interface to reflect current input states, display selected options, and guide users through input
sequences.

9. **Accessibility Considerations**:

- Consider accessibility needs such as tactile feedback for visually impaired users or larger buttons for users with
motor disabilities.

- Ensure that input devices and interaction flows accommodate diverse user needs and preferences.

10. **Testing and Iteration**:

- Test the input design thoroughly to ensure functionality, usability, and reliability under various usage
scenarios.

- Gather feedback from users or stakeholders and iterate on the input design based on usability testing results
and user preferences.

2. Output Design:-

3. **Display Selection**: Choose the appropriate display technology based on factors such as readability,
power consumption, and available resources. Options include LEDs, LCDs, OLEDs, or 7-segment
displays.
4. **Display Layout**: Design the layout and arrangement of display elements to clearly and legibly
present time information. Consider factors such as font size, digit placement, and spacing to optimize
readability.

5. **Time Format**: Determine the format for displaying time information, including hours, minutes,
and seconds. Choose between 12-hour or 24-hour formats based on user preferences and regional
conventions.

6. **Display Update Frequency**: Define the update frequency for refreshing display elements to ensure
smooth and accurate representation of time information. Balance refresh rate with power
consumption considerations for efficient operation.

7. **Brightness Control**: Implement brightness control mechanisms to adjust display luminance based
on ambient lighting conditions or user preferences. Provide options for manual adjustment or
automatic brightness adjustment.

8. **Alarm Indicators**: Include visual and auditory indicators to notify users of active alarms or
upcoming alarm events. Use flashing LEDs, color changes, or alarm tones to attract attention and
prompt user response.

9. **Temperature Display (Optional)**: If the clock includes temperature sensing capabilities, design the
display layout to incorporate temperature information alongside time data. Ensure clarity and
coherence in presenting dual information displays.

10. **User Interface Integration**: Integrate output elements seamlessly with the user interface to
provide a cohesive and intuitive user experience. Ensure consistency in design language and
interaction patterns across display elements.

11. **Error Messages and Alerts**: Design output displays to communicate error messages, warnings, or
system alerts effectively. Use clear and concise messaging to convey information and guide users in
troubleshooting issues.

12. **Power Saving Modes**: Implement power-saving modes for display elements to conserve energy
during periods of inactivity. Dim displays or enter low-power states to reduce power consumption
while maintaining essential functionality.

13. Code Design:-


1. **Modular Structure**: Organize the code into modular components to facilitate maintainability,
reusability, and scalability. Separate functionalities such as timekeeping, display control, input handling,
and alarm management into distinct modules.

2. **Header Files**: Define header files to encapsulate function prototypes, data structures, and global
constants used throughout the codebase. Use header files to promote code readability and modularity.

3. **Initialization Routine**: Develop an initialization routine to set up hardware peripherals, initialize data
structures, and configure system parameters. This routine ensures that the digital clock starts in a known
and stable state upon power-up.

4. **Main Loop**: Implement the main loop of the firmware to execute core functionalities such as time
updating, input handling, display refreshing, and alarm management. Use an infinite loop structure to
continuously monitor and respond to system events.

5. **Timekeeping Logic**: Write functions to manage timekeeping operations, including reading time from
the real-time clock (RTC) module, updating internal time variables, and handling time adjustments.

6. **Display Control Functions**: Define functions to control the display unit, including routines to update
display segments, format time data for display, and adjust brightness levels. Implement algorithms to
refresh the display at regular intervals.

7. **Input Handling Functions**: Develop functions to handle user inputs from buttons, switches, or a
touchscreen interface. Interpret user actions, such as setting time, configuring alarms, and adjusting
settings, based on input signals.

8. **Alarm Management Functions**: Create functions to manage alarm settings, including setting, updating,
and disabling alarms. Implement logic to trigger alarm events, play alarm tones, and handle snooze
functionality.

9. **Error Handling Mechanisms**: Implement error detection and handling mechanisms to manage
exceptional conditions, such as communication errors with hardware peripherals or invalid user inputs.
Provide informative error messages or feedback to guide users in resolving issues.

10. **Documentation and Comments**: Document code extensively with comments and descriptive function
headers to explain its purpose, usage, and behavior. Use meaningful variable names and clear coding
conventions to enhance code readability and maintainability.
11. **Testing and Debugging**: Test the code thoroughly under various scenarios and conditions to ensure
functionality, reliability, and robustness. Use debugging tools and techniques to identify and resolve
software bugs or logical errors.

14. Modules:-

1. **Timekeeping Module**:

- Responsibilities:

- Retrieve time data from the real-time clock (RTC) module.

- Update internal time variables based on RTC readings.

- Provide functions for time formatting and manipulation.

2. **Display Control Module**:

- Responsibilities:

- Control the display unit to show time and other information.

- Implement functions to update display segments or pixels.

- Manage display brightness and refresh rate.

3. **Input Handling Module**:

- Responsibilities:

- Handle user inputs from buttons, switches, or a touchscreen interface.

- Interpret user actions for setting time, alarms, and adjusting settings.

- Implement debouncing and validation to ensure reliable input detection.

4. **Alarm Management Module**:

- Responsibilities:

- Manage alarm settings, including setting, updating, and disabling alarms.

- Handle alarm triggering, alarm tone playback, and snooze functionality.

- Implement logic for managing multiple alarms and recurring alarms.

5. **User Interface Module**:

- Responsibilities:

- Design the user interface to interact with the digital clock.


- Provide menus, prompts, and feedback mechanisms for user interactions.

- Handle display of current time, alarm settings, and configuration options.

6. **Power Management Module**:

- Responsibilities:

- Manage power consumption to optimize energy efficiency.

- Implement power-saving modes to conserve energy during idle periods.

- Handle power source switching and battery monitoring (if applicable).

7. **Error Handling Module**:

- Responsibilities:

- Detect and handle errors or exceptional conditions in the system.

- Provide error messages or feedback to guide users in resolving issues.

- Implement mechanisms for fault tolerance and system recovery.

8. **Communication Module (Optional)**:

- Responsibilities:

- Facilitate communication with external devices or systems (e.g., internet time servers, smart home platforms).

- Handle data exchange protocols such as Bluetooth, Wi-Fi, or serial communication.

- Integrate with APIs for fetching additional information (e.g., weather forecasts).

9. **Testing and Debugging Module**:

- Responsibilities:

- Conduct comprehensive testing of the digital clock firmware.

- Implement debugging features and tools to identify and resolve software bugs.

- Develop testing routines and scripts for automated testing.

10. **Documentation Module**:

- Responsibilities:

- Document code extensively with comments, function headers, and usage instructions.

- Provide user manuals, technical documentation, and troubleshooting guides.

- Document hardware specifications, pin mappings, and external dependencies.

CHAPTER 4
SYSTEM INFORMATIONS

In the context of the Contact Book System, system information refers to the details about the
environment, dependencies, and configurations required to run the application effectively. Here's a
breakdown of the system information for the project:
1. Operating System Compatibility:
Specify the operating systems supported by the Contact Book System. This could include:
Windows
macOS
Linux distributions (e.g., Ubuntu, CentOS)
2. Programming Language and Version:
Identify the programming language used to develop the system and its version. For example:
Python 3.x
3. Web Framework and Dependencies:
If the system includes a web-based user interface, specify the web framework used and its
dependencies. For instance:
Flask or Django
List any additional Python packages required for the web framework (e.g., Flask-WTF, Django Rest
Framework)
4. Database Management System:
Specify the database management system (DBMS) used for storing contact information. This could
be:
MySQL
PostgreSQL
SQLite (for development/testing purposes)
5. Database Connection Information:
Provide details about the database connection, including:
Hostname/IP address
Port number
Database name
Username and password (if applicable)
Connection URL or configuration file path
6. Web Server Information (if applicable):
If the system is deployed on a web server, specify details about the web server software:
Apache HTTP Server
Nginx
Microsoft Internet Information Services (IIS)
7. Browser Compatibility:
Mention the web browsers supported by the system's user interface:
Google Chrome
Mozilla Firefox
Microsoft Edge
Safari
8. Other Dependencies and Configurations:
Include any other dependencies or configurations required to run the system, such as:
JavaScript libraries (e.g., jQuery, Bootstrap)
Additional Python packages/modules
Environment variables
Configuration files (e.g., for application settings, logging)
9. Deployment Environment:
Specify whether the system is intended for deployment in a production environment or for
development/testing purposes.
Provide information about the deployment environment, such as:
Cloud platform (e.g., AWS, Azure, Google Cloud)
On-premises server
Docker containerization
10. System Architecture Diagram (optional):
Optionally, include a system architecture diagram depicting the components and interactions of the
Contact Book System within the broader system environment.

CHAPTER 5
CONCLUSION

One of the most well-known and most used feature of devices to all users, developers or not, is the
Contact Book. For those who use a lot the device as a phone all important and vital information they
need exist in their contacts. Till today, many applications have been developed, and even more can be
built that make use the device’s Contact book data Contact Book is a contact management software,
wherewith you can note the addresses, phone numbers, mobile, fax, company name, country, city,
website address and email addresses of your contacts and partners. You can easy print list of contacts
and details of selected contact, has a local database and user interface for finding and editing information
about people 31
Future Works:
The work done in project can be extended along several interesting directions, among these are:
1- This project can be applied in distributed databases.
2- This project can be online Contact book.
3- This project can be applied to other programming languages.

CHAPTER 6
REFERANCES

https://www.pyforschool.com/project/contact-book-python-mysql-project.html
[email protected]
https://www.youtube.com/watch?v=4JqYUUFksAc
https://en.wikipedia.org/?title=Contact_book&redirect=no
https://www.smartdraw.com/about/contact.htm
https://www.clarity-ventures.com/blog/the-importance-of-a-custom-address-book-for-ecommerce
https://asp.net/ajax

CHAPTER 7
SOURCE CODE

import mysql.connector
import time

db = mysql.connector.connect(
host="localhost",
user="root",
password="srini@12345",
database="contactbook"
)

cursor = db.cursor()

cursor.execute("""
CREATE TABLE IF NOT EXISTS book (
name char(30) primary key,
address char(100),
mobile char(15),
email char(30)
);
""")

def intro():
print("=" * 80)
print("{:^80s}".format("CONTACT"))
print("{:^80s}".format("BOOK"))
print("{:^80s}".format("PROJECT"))
print("{:^80s}".format("MADE BY: PyForSchool.com"))
print("=" * 80)
print()
time.sleep(2)
def create_record():
name = input("Enter name: ")
address = input("Enter address: ")
mobile = input("Enter mobile: ")
email = input("Enter email: ")
sql = "INSERT INTO book(name,address,mobile,email) VALUES (%s,%s,%s,%s)"
record = (name, address, mobile, email)
cursor.execute(sql, record)
db.commit()
print("Record Entered Successfully\n")

def search(name):
sql = "SELECT * FROM book WHERE name = %s"
value = (name,)
cursor.execute(sql, value)
record = cursor.fetchone()
if record is None:
print("No such record exists")
else:
print('Name:', record[0])
print('Address:', record[1])
print('Mobile:', record[2])
print('E-mail:', record[3])

def display_all():
cursor.execute("SELECT * FROM book")
print('{0:20}{1:30}{2:15}{3:30}'.format('NAME', 'ADDRESS', 'MOBILE NO', 'E-MAIL'))
for record in cursor:
print('{0:20}{1:30}{2:15}{3:30}'.format(record[0], record[1], record[2], record[3]))

def delete_record(name):
sql = "DELETE FROM book WHERE name = %s"
value = (name,)
cursor.execute(sql, value)
db.commit()
if cursor.rowcount == 0:
print("Record not found")
else:
print("Record deleted successfully")

def modify_record(name):
sql = "SELECT * FROM book WHERE name = %s"
value = (name,)
cursor.execute(sql, value)
record = cursor.fetchone()
if record is None:
print("No such record exists")
else:
while True:
print("\nPress the option you want to edit: ")
print("1. Name")
print("2. Address")
print("3. Mobile")
print("4. BACK")
print()
ch = int(input("Select Your Option (1-4): "))
if ch == 1:
new_name = input("Enter new name: ")
sql = "UPDATE book SET name = %s WHERE name = %s"
values = (new_name, name)
cursor.execute(sql, values)
db.commit()
print(cursor.rowcount, "record updated successfully")
elif ch == 2:
new_address = input("Enter new address: ")
sql = "UPDATE book SET address = %s WHERE name = %s"
values = (new_address, name)
cursor.execute(sql, values)
db.commit()
print(cursor.rowcount, "record updated successfully")
elif ch == 3:
new_mobile = input("Enter new mobile : ")
sql = "UPDATE book SET mobile = %s WHERE name = %s"
values = (new_mobile, name)
cursor.execute(sql, values)
db.commit()
print(cursor.rowcount, "record updated successfully")
elif ch == 4:
break
else:
print("Invalid choice !!!\n")

def main():
intro()
while True:
print("\nMAIN MENU ")
print("1. ADD NEW RECORD")
print("2. SEARCH RECORD")
print("3. DISPLAY ALL RECORDS")
print("4. DELETE RECORD")
print("5. MODIFY RECORD")
print("6. EXIT")
print()
ch = int(input("Select Your Option (1-6): "))
print()
if ch == 1:
print("ADD NEW RECORD")
create_record()
elif ch == 2:
print("SEARCH RECORD BY NAME")
name = input("Enter name: ")
search(name)
elif ch == 3:
print("DISPLAY ALL RECORDS")
display_all()
elif ch == 4:
print("DELETE RECORD")
name = input("Enter name: ")
delete_record(name)
elif ch == 5:
print("MODIFY RECORD")
name = input("Enter name: ")
modify_record(name)
elif ch == 6:
print("Thanks for using Contact Book")
db.close()
break
else:
print("Invalid choice")

main()

CHAPTER 8
SCREEN LAYOUT

You might also like