0% found this document useful (0 votes)
432 views29 pages

Cyber Cafe Management

A pyrhon my sql connectivity program

Uploaded by

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

Cyber Cafe Management

A pyrhon my sql connectivity program

Uploaded by

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

AGARWAL VIDYALAYA AND JUNIOR

COLLEGE

COMPUTER SCIENCE
PROJECT

SESSION:2024-2025

A PROJECT REOPORT ON:


“CYBER CAFE MANAGEMENT”

Under the Guidance of


SUBMITTED BY:
Aryan Pagaria MRS.RANI MAM
CLASS:XII-A Computer Science
PAGE.
S.NO DESCRIPTION
NO

1. CERTIFICATE 1

2. INTRODUCTION 2

3. OBJECTIVE OF THE PROJECT 6

4. PROPOSED SYSTEM 7

MODULES USED AND THEIR


5. 8
PURPOSES

6. SOURCE CODE 10

7. OUTPUT SCREENS 20

8. LIMIT AND FUTURE SCOPES 23

9. REQUIREMENTS 24

10. BIBLIOGRAPHY 25
CERTIFICATE

AGARWAL VIDYALAYA AND JUNIOR COLLEGE


(A UNIT OF AGARWAL RELIEF & EDUCATIONAL TRUST)
No.54, EVK SAMPATH ROAD, VEPERY, CHENNAI - 600007

CERTIFIED TO BE A BONAFIDE RECORD OF

PROJECT WORK IN COMPUTER SCIENCE

DONE BY :

1.ADITYA PARMAR

2.ARYAN PAGARIA

3.KAILASH.S

OF CLASS XII DURING THE YEAR 2024-2025.

DATE :
REGISTER NO :

1
Introduction

About Cyber Cafe Management:


This project is a comprehensive Cyber Cafe Management
System built in Python, designed to streamline the operations
of a cyber cafe. The system integrates with a MySQL
database to manage customer information, track PC usage,
and generate billing statements. The primary goal of the
project is to provide an efficient, user-friendly solution for
managing cyber cafe resources and services.

The system allows customers to register and log in, select and
use available PCs, and end their sessions with automated time
tracking. It also includes an admin interface for overseeing daily
operations, such as viewing active sessions, managing
customer records, and generating bills based on session usage.
The use of MySQL ensures secure data storage and efficient
retrieval for both customers and administrators. Overall, the
project demonstrates effective database management, session
handling, and payment processing in a real-world application
setting.

2
Features of Python :-
1. Easy :-
Python is a very easy to learn and understand; using this python tutorial,
any beginner can understand the basics of python.

2. Interpreted :-
It is interpreted (executed) line by line. This makes it easy to test and
debug.
3. Object Oriented :-
The python programming language supports classes and objects.
4. Free and Open-Source :-
The language and it‟s source code are available to the public for free;
there is no need to buy a costly license.
5. Portable :-
Since it is open source, we can run python on windows, mac, linux, or
any other platforms. Our programs will work without needing to the
changed for every machine.
6. GUI (Graphical User Interface) programming :-
We can use it to develop a GUI (Graphical User Interface). One way to
do this is through “Tkinter‟.
7. Large Library :-
Python provides us with a large standard library. We can use it to
implement a variety of functions without needing to reinvent the wheel
every time. Just pick the code we need and continue. This lets us to
focus on other important tasks.

3
Advantages of Python :-

1. Extensible :-
2. Portable
3. Free & Open-Source
4. Readable
5. Embeddable
6. Improved Productivity
7. Simple and Easy
8. Object Oriented
9. Interpreted
10. Extensive Libraries

How to install Python :-


1. Point your web browser to the download page on the Python website
(www.python.org).
2. Select the latest Windows x86 MSI Installer and click on the link to
download the .msi installer.
3. Run the installer.
4. Select ,Install for all users‟ and click the Next > button.
5. Keep the default option (C:\Python32\) as the destination directory and
click Next > again.
6. Don’t make any changes in the,Customize Python 3.2.3‟ dialog, just
click Next > again.
7. Click Yes if asked if this program should be allowed to install software
on your system.
8. Click the Finish button when installation completes.

4
About MySql :-
MySql is a fast, easy to use RDBMS (Relational Database Management
System) being used for many small and big businesses. MySql is developed,
marketed and supported by MySQL AB, which is a Swedish Company. MySql
is becoming is so popular because of many good reasons:-

1. MySql is released under an open-source language. So we have nothing


to pay to use it.
2. MySql is a very powerful program in it‟s own right. It handles a large
subset of the functionality of the most expensive and powerful database
packages.
3. MySql uses a standard form of the well-known SQL data language.
4. MySql works on many operating system and with many languages
including PHP, PERL, C, C++, JAVA, etc.
5. MySql works very quickly and works well even with large data sets.
6. MySql is very friendly to PHP, the most appreciated language for web
development.
7. MySql supports large databases, up to 50 million rows or more in a
table. The default file size limit for a table is 4 GB, but we can increase
this (if our operating system can handle) to a theoretical limit of 8
millions Tera-Bytes (TB).
8. MySql is customizable. The open-source GPL license allows
programmers to modify the MySql software to fit their own specific
environments.

For installing MySql :-


1. For Python 2.7 or lower, install using pip as :-
pip install mysql.connector

2. For Python 3 or higher version, install using pip3 as :-


pip3 install mysql.connector

5
Objective of the project
The objective of this project is to let the students apply the
programming knowledge into a real-world situation/problem and
exposed the students how programming skills help in developing
a good software.

Some key points are as follows :-

1. Utilising modern software tools for programming games.


2. Apply object oriented programming principles effectively
when developing small to medium sized projects.
3. Write effective procedural code to solve small to medium sized
problems
4. Demonstrate a breadth of knowledge in computer science,
as exemplified in the Cyber cafe management program

5.Demonstrate ability to conduct a research or applied


computer science project, requiring writing and presentation
skills which exemplify scholarly style in computer science.

6
Proposed System
The proposed system for the Cyber Cafe Management System aims to automate and
simplify the day-to-day operations of a cyber cafe. The system will manage customer
information, track PC usage, calculate session times, and generate billing information,
all while providing administrative functionality to oversee operations efficiently.

Key Features:
1. Customer Registration and Login:
The system allows new customers to register with their details (email, name,
phone number, and password).
Registered customers can log in and access available PCs, manage their
session timings, and receive bills based on their usage.
2. PC Session Management:
The system tracks when a customer starts and ends their PC session.
It calculates the duration of the session and automatically assigns charges
based on the time used.
3. Billing System:
After each session, the system generates a bill based on the customer’s
session time and predefined rates (e.g., rate per hour).
The system saves this bill in the database for both customer and admin
reference.
4. Admin Functionality:
Administrators can log in and view a summary of all ongoing and completed
sessions, including customer usage records.
Admins can manage customer bills, view the current status of all PCs, and end
sessions remotely if needed.
5. Database Management:
The system is integrated with a MySQL database to store customer details,
session usage records, and billing information.
It ensures data is securely stored, making retrieval efficient for both customers
and administrators.
Benefits of the Proposed System:
Automation of Manual Tasks: The system eliminates the need for manual record-
keeping, reducing human error and improving accuracy in billing and session
management.
Efficient Resource Management: By tracking the status of each PC, administrators
can ensure PCs are being used efficiently and manage peak usage times
effectively.
This proposed system ensures efficient management of cyber cafe operations,
improving both customer satisfaction and the ease of managing multiple users and
PCs.

7
Module used and their purposes

1. MySql.connector module :-

This module enables python programs to access MySQL databases, using an


API that is compliant with the Python Database API Specification v2.0 (PEP
249). It is written in pure Python and does not have any dependencies except
for the Python Standard Library.

MySql.connector module has a set of methods in which one is used in that


game.

a. cursor ( ) :-
A database cursor is a useful control structure of database
connectivity. Normally when we connect to a database from within a
script/program, then the query gets sent to the server, where it gets
executed, and the set of records retrieved as per query is sent over the
connection.

The syntax for using this function is „conn.cursor ( )‟.

b. connect ( ) :-
After we have installed Python MySql connector, we can write
python scripts using MySql.connector library that can connect to
MySql databases from within Python. Next we need to establish
connection to a MySql database using connect() function of
mysql.connector package.

The connect() function of mysql.connector establishes connection to


a MySql database and requires four parameters, which are :

<connection-object>=mysql.connector.connect(
host=<host- name>,
user=<username>,
passwd=<password>.
database=<database>)

8
- user is the username on MySql
- password is the password of the user
- host-name is the database server hostname or IP address
- database is optional which provides the database name of
a MySql database.

The syntax for using this function is :- “mysql.connector.connect()‟.

c. execute ( ) :-
This method is used to executes an SQL statement. Once we have
created a cursor, we can execute SQL query using execute() function
with cursor object .

The syntax for using this method is “cursor.execute()‟.

For example,
If we want to view all the records of table data which is a table in the
database test to which we established connection, we can execute SQL
query “select * from data” by writing:

‘cursor.execute(“select * from data”)’

2. Date time module:


The datetime module in Python provides classes to manipulate dates
and times. It is widely used for handling date and time objects,
performing arithmetic on dates, formatting and parsing date strings,
and working with time zones. In this script, the datetime and timedelta
classes are imported from the datetime module.
Here’s a brief breakdown of how the module is structured and used:

Classes within the datetime Module:


Datetime: Represents both date and time in one object.
Date: Represents just the date (year, month, and day).
Time: Represents the time (hour, minute, second,
microsecond).
Timedelta: Represents a duration or difference between two
dates/times.
Tzinfo: Provides time zone information

9
Source
Code

10
import mysql.connector
from datetime import datetime, timedelta

# Database connection
def connect_to_database():
try:
conn = mysql.connector.connect(
host="localhost",
user="root",
password="pagaria_2006",
database="cybercafe101"
)
return conn
except mysql.connector.Error as err:
print(f"Error connecting to MySQL: {err}")
return None
# Initialize database and tables
def initialize_database():
db = connect_to_database()
if not db:
print("Unable to connect to the database. Please check your MySQL connection.")
return

cursor = db.cursor()

try:
cursor.execute("CREATE DATABASE IF NOT EXISTS cybercafe101")
cursor.execute("USE cybercafe101")

cursor.execute('''
CREATE TABLE IF NOT EXISTS customers (
email VARCHAR(255) PRIMARY KEY,
name VARCHAR(255) NOT NULL,
phone VARCHAR(20) NOT NULL,
password VARCHAR(255) NOT NULL
)
''')

11
cursor.execute('''
CREATE TABLE IF NOT EXISTS usage_records (
id INT AUTO_INCREMENT PRIMARY KEY,
customer_email VARCHAR(255),
pc_id INT NOT NULL,
start_time DATETIME NOT NULL,
end_time DATETIME NOT NULL,
hours FLOAT NOT NULL,
is_active BOOLEAN DEFAULT TRUE,
FOREIGN KEY (customer_email) REFERENCES customers(email)
)
''')

cursor.execute('''
CREATE TABLE IF NOT EXISTS bills (
id INT AUTO_INCREMENT PRIMARY KEY,
customer_email VARCHAR(255),
amount DECIMAL(10, 2) NOT NULL,
date DATE NOT NULL,
FOREIGN KEY (customer_email) REFERENCES customers(email)
)
''')

db.commit()
print("Database and tables initialized successfully.")
except mysql.connector.Error as err:
print(f"Error initializing database: {err}")
finally:
cursor.close()
db.close()
except mysql.connector.Error as err:
print(f"Error initializing database: {err}")
finally:
cursor.close()
db.close()

12
class Customer:
def __init__(self, email, name, phone):
self.email = email
self.name = name
self.phone = phone

def calculate_bill(self, hours, rate_per_hour):


return hours * rate_per_hour

class PC:
def __init__(self, pc_id):
self.pc_id = pc_id
self.in_use = False
self.current_user = None
self.end_time = None

def start_session(self, customer, hours):


self.in_use = True
self.current_user = customer
self.end_time = datetime.now() + timedelta(hours=hours)

def end_session(self, db_connection):


if self.in_use:
cursor = db_connection.cursor()
try:
cursor.execute("""
UPDATE usage_records
SET is_active = FALSE
WHERE customer_email = %s AND pc_id = %s AND is_active = TRUE
""", (self.current_user.email, self.pc_id))
db_connection.commit()
print(f"\nPC {self.pc_id} session has ended. The PC has been locked.")
self.in_use = False
self.current_user = None
self.end_time = None
except mysql.connector.Error as err:
print(f"Error ending session in database: {err}")
finally:
cursor.close()
else:
print(f"PC {self.pc_id} is not in use.")
13
pcs = [PC(i) for i in range(1, 11)]

def register_new(cursor):
email = input("Enter your email: ")
name = input("Enter your name: ")
phone = input("Enter your phone number: ")
while True:
password = input("Create a password: ")
confirm_password = input("Confirm your password: ")
if password == confirm_password:
break
else:
print("Passwords do not match. Please try again.")

cursor.execute("INSERT INTO customers (email, name, phone, password) VALUES


(%s, %s, %s, %s)",
(email, name, phone, password))
return Customer(email, name, phone)

def login_customer(cursor):
email = input("Enter your email: ")
password = input("Enter your password: ")

cursor.execute("SELECT * FROM customers WHERE email = %s AND password =


%s", (email, password))
result = cursor.fetchone()

if result:
return Customer(result[0], result[1], result[2])
else:
print("Invalid email or password.")
return None

def check_active_session(cursor, customer_email):


cursor.execute("""
SELECT * FROM usage_records
WHERE customer_email = %s AND end_time > NOW() AND is_active = TRUE
""", (customer_email,))
return cursor.fetchone()

14
def customer_interface():
print("Welcome to the Gaming PC Cyber Cafe")

db = connect_to_database()
if not db:
print("Unable to connect to the database. Please try again later.")
return

cursor = db.cursor()

try:
while True:
choice = input("1. Login\n2. Register\n3. Exit\nEnter your choice: ")
if choice == '1':
customer = login_customer(cursor)
if customer:
break
elif choice == '2':
customer = register_new(cursor)
db.commit()
print("Registration successful! Please login.")
elif choice == '3':
return
else:
print("Invalid choice. Please try again.")

if not customer:
return

print(f"Welcome, {customer.name}!")

active_session = check_active_session(cursor, customer.email)

if active_session:
pc_id = active_session[2]
end_time = active_session[4]
print(f"You have an active session on PC {pc_id} ending at
{end_time.strftime('%H:%M:%S')}")
return

15
print("\nAvailable PCs:")
available_pcs = [pc for pc in pcs if not pc.in_use]
for pc in available_pcs:
print(f"PC {pc.pc_id}")

if not available_pcs:
print("Sorry, all PCs are currently in use. Please try again later.")
return

while True:
try:
pc_id = int(input("Enter the PC number you want to use: "))
selected_pc = next((pc for pc in available_pcs if pc.pc_id == pc_id), None)
if selected_pc:
break
else:
print("Invalid PC selection. Please choose an available PC.")
except ValueError:
print("Please enter a valid number.")

while True:
try:
hours = float(input("How many hours will you be using the PC? "))
if hours > 0:
break
else:
print("Please enter a positive number of hours.")
except ValueError:
print("Please enter a valid number.")

selected_pc.start_session(customer, hours)

start_time = datetime.now()
end_time = start_time + timedelta(hours=hours)

cursor.execute("""
INSERT INTO usage_records
(customer_email, pc_id, start_time, end_time, hours, is_active)
VALUES (%s, %s, %s, %s, %s, TRUE)
""", (customer.email, pc_id, start_time, end_time, hours))
db.commit()
16
rate_per_hour = 100
bill_amount = customer.calculate_bill(hours, rate_per_hour)
print(f"Your bill amount is: ₹{bill_amount:.2f}")

cursor.execute("INSERT INTO bills (customer_email, amount, date) VALUES (%s,


%s, %s)",(customer.email, bill_amount, start_time.date()))
db.commit()
print(f"Your session will end at {end_time.strftime('%H:%M:%S')}")

except mysql.connector.Error as err:


print(f"An error occurred: {err}")
finally:
cursor.close()
db.close()

def admin_interface():
print("Admin Interface")
password = input("Enter admin password: ")

if password != "admin123":
print("Invalid password")
return

db = connect_to_database()
if not db:
print("Unable to connect to the database. Please try again later.")
return

cursor = db.cursor(dictionary=True)
try:
while True:
print("\n1. View all usage records")
print("2. View customer bills")
print("3. View current PC status")
print("4. End a PC session")
print("5. Exit")
choice = input("Enter your choice: ")

17
if choice == "1":
cursor.execute("SELECT * FROM usage_records")
records = cursor.fetchall()
for record in records:
print(record)
elif choice == "2":
cursor.execute("SELECT * FROM bills")
bills = cursor.fetchall()
for bill in bills:
print(bill)
elif choice == "3":
for pc in pcs:
status = "In use" if pc.in_use else "Available"
user = pc.current_user.email if pc.current_user else "N/A"
end_time = pc.end_time.strftime('%H:%M:%S') if pc.end_time else "N/A"
print(f"PC {pc.pc_id}: {status}, User: {user}, End Time: {end_time}")
elif choice == "4":
pc_id = int(input("Enter the PC number to end session: "))
pc_to_end = next((pc for pc in pcs if pc.pc_id == pc_id), None)
if pc_to_end and pc_to_end.in_use:
pc_to_end.end_session(db)
else:
print("Invalid PC number or PC is not in use.")
elif choice == "5":
break
else:
print("Invalid choice")
except mysql.connector.Error as err:
print(f"An error occurred: {err}")
finally:
cursor.close()
db.close()

18
def main_loop():
initialize_database()
while True:
print("\n1. Customer Login/Register")
print("2. Admin Login")
print("3. Exit")
choice = input("Enter your choice: ")

if choice == "1":
customer_interface()
elif choice == "2":
admin_interface()
elif choice == "3":
break
else:
print("Invalid choice")

print("Thank you for using the Cyber Cafe Management System!")

if __name__ == "__main__":
main_loop()

19
Output
Screens

20
1.Registering a new account:-

2. Login from new account:-

21
3.Admin login and to view all usage records

4.To view customer bills:-

5.View current statuts of pc:-

6.To end a pc session:-

22
7.Mysql output:
Limitations and Future Scope

Limitations :-
Only one player can register at a time.
user can use the pc till the specific time
It does provide timing system.

Future Scope :-

We can register more than one user


Registration of players can be done.
Timing system is provided.

23
Requirements
Hardware required :-

Modern Operating System:


Windows 7 or 10
Mac OS X 10.11 or higher, 64-bit
Linux: RHEL 6/7, 64-bit (almost all libraries also work in Ubuntu)

X86 64-bit CPU (Intel / AMD architecture)


4 GB RAM
5 GB free
Printer for printing project

Software required :-

Operating System – Windows 10


Python 3.11.4
MS word, for preparing documentation

24
Bibliography
1. www.google.com
2. www.youtube.com
2. Computer Science with Python
by Sumita Arora Class XII(Book)

25
Thank You!!

26

You might also like