marriage bureau project

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 27

BAL BHAVAN

PUBLIC SR.SEC
SCHOOL

COMPUTER SCIENCE

PROJECT FILE

Marriage Bureau
RAGHAV ,HARSH AND
JUNAID
XII-COMMERCE ‘A’

1
ACKNOWLEDGEMENT

In completing this project successfully, I want to express my heartfelt gratitude


to several people who supported and encouraged me along the way.
I would like to express my sincere gratitude to Mrs.Suchita Mittal , my
respected teacher, for her unwavering support and guidance throughout the
development of this project. Her valuable insights and encouragement have
been instrumental in bringing this project to fruition.

Thank you, Suchita ma’am, for your continuous support.

Lastly, a big thank you to my Project Partners who contributed to the


completion of this project. His support and motivation were invaluable, and I
appreciate him for being a part of this journey.

2
TABLE OF CONTENTS:

S.NO TOPIC PAGE NO

01. Introduction

02. Modules and Data Files Used

03. Code of the Project

04. Output

3
INTRODUCTION
Welcome to the Marriage Bureau System – a digital service designed
to simplify the process of finding life partners. This project is a
marriage of technology and human connection, aimed at helping
individuals discover their ideal match.
The Project is entirely coded in python and SQL. And uses both of
them together to form a smooth seamless technology that lets a user to
Create Profile, update, delete or search for the profile in the database
and even create a match for 2 profiles.

Technologies Used:

1. **Python:** The primary programming language used for the


project.
In our Class 12th journey, Python is like that superhero language
simple but super powerful.

How Python Helped Make the Marriage Bureau Project:

1. Easy to Understand: Python's simple code made everything


clear and easy to read. No confusing stuff, just straightforward
solutions.
2. Does Many Tricks: Python is like an all-rounder language. It
can connect smoothly with a MySQL database, making it a
champ in handling data using SQL.

3. Tools: Python comes with a bunch of tools. These tools helped


us make sure everything works smoothly, making our project
strong and reliable.
4. Building the Project: It helped us create a user-friendly
interface, smart algorithms, and a system to manage data like a
pro.

In simple words, learning Python in Class 12th isn't just about coding.
It's about gaining the power to turn ideas into real things.

4
2. SQL: Structured Query Language facilitates seamless interaction
with the database.

In Class 12th, our academic journey introduces us to the structured


query language, popularly known as SQL. This subject holds
significance as it helps us to understand the database management
systems and data manipulation.

Role of SQL in the Marriage Bureau Project:

1. Database Management Mastery: SQL facilitated efficient


database management within the Marriage Bureau project. Its
structured approach to organizing, storing, and retrieving data ensured
systematic data handling.

2. Data Safety Assurance: SQL's emphasis on data safety/security


played a pivotal role in maintaining accuracy and consistency across
the Marriage Bureau database. This is fundamental for any project
where precision is a must.

3. Powerful Data Querying: The project's functionality was


enhanced by SQL's ability in querying data. Through skillful
manipulation of SQL queries, we were able to extract, filter, and
analyze data with precision.

In essence, SQL in Class 12th is more than a subject; it is a gateway


to proficiently managing and extracting meaningful insights from vast
datasets. The Marriage Bureau project stands as a testament to the
application of SQL principles in a real-world scenario.

How It Works:

- User Profiles: The project allows users to create detailed profiles,


capturing personal, professional, and preference-related details The
user is asked to fill different details such as their Occupation, Annual

5
Income, their height, preferences while choosing a partner,
educational qualification and much more.

- Data Display: A user-friendly interface displays information stored


in the database, providing an overview of available tables. The data is
displayed on the command line in rows and columns, the first row
tells us the name of all the columns and the other rows contains the
data and shows it to us on the command line.

- Data Modification and Searching: Users can update their


information as needed, ensuring their profiles remain current. The
user is asked to enter either the user Id or the first name and then
displays the person whos’d data you want to search, and in a similar
fashion, the data can be updated as well.

-Data Deletion: The data can also be deleted in a similar fashion, one
can search for the data to be deleted and then can delete the data
accordingly.

Implementation Steps for the Marriage Bureau Project:

1. Database Setup:
- Run the "Create Table.py" Python script to set up the initial
database tables. This script prompts you to enter the MySQL database
password. If the database does not exist, it will be created.

2. Main Program Execution:


- Execute the "Main Program.py" file to launch the main program of
the Marriage Bureau application. This serves as the entry point for
various functionalities.

3. User Registration:
- Choose the option to "Add User Details" from the main menu.
Follow the prompts to input login credentials, career details, personal
information, and preferences. This information is stored in the
corresponding database tables.

6
4. Match Registration:
- Opt for the "Add Match" option to register a match between two
users. Input the user IDs, match status, and the date of the match. The
match details are stored in the "Matches" table.

5. Data Display:
- Use the "Display Data" option to view information from different
tables. Select the table you want to display, and the program fetches
and presents the data in a tabular format.

6. Data Update:
- Select the "Update Data" option to modify existing records.
Choose the table and column you wish to update, provide the User ID,
and enter the new value. The updated data is then reflected in the
database.

7. Data Search:
- Utilize the "Search Data" option to find specific records. You can
search by User ID or First Name, depending on your preference. The
program displays the relevant information if a match is found.

8. Data Deletion:
- Choose the "Delete Data" option to remove a user's data along
with associated records in other tables. Enter the User ID, and the
program deletes all data linked to that user.

9. Application Exit:
- To exit the application, select the "Exit" option from the main
menu. This gracefully concludes the program.

Important Notes:
- Ensure that the MySQL server is running before executing the
scripts.
- Follow the on-screen instructions and input data accurately to

7
maintain data integrity.
- Password protection is critical for database access; ensure the
security of your MySQL password.

By following these steps, users can interact with the Marriage Bureau
application, register and manage user details, track matches, and
perform various database operations efficiently.

Important Modules, Terms and Functions in the Marriage


Bureau Project:

1. MySQL Connector (mysql):


- Description: The `mysql.connector` is a Python module that
provides connectivity to a MySQL database.
- Significance in the Project: It serves as the bridge between Python
and the MySQL database, facilitating seamless communication.

2. Cursor:
- Description: In database operations, a cursor is a control structure
that enables traversal over the records in a database.
- Significance in the Project: The `cursor` in the Marriage Bureau
project is crucial for executing SQL queries and fetching results from
the database.

3. Database Connection (mydb):


- Description: The database connection is a link between the Python
program and the MySQL database, allowing the exchange of data.
- Significance in the Project: `mydb` handles the connection to the
Marriage Bureau database, enabling the execution of queries and
transactions.

4. INSERT INTO Statement:


- Description: The SQL `INSERT INTO` statement is used to insert
new records into a table.
- Significance in the Project: It plays a pivotal role in adding user
details, matches, and other essential information to the respective
tables in the Marriage Bureau database.

8
5. DESCRIBE Statement:
- Description: The SQL `DESCRIBE` statement is used to retrieve
metadata about a table, such as column names and their data types.
- Significance in the Project: It assists in dynamically fetching
column names and their characteristics, aiding in various database
operations.

6. SELECT Statement:
- Description: The SQL `SELECT` statement is used to retrieve data
from one or more tables in a database.
- Significance in the Project: It is employed to fetch and display data
from different tables, providing valuable insights and information.

7. UPDATE Statement:
- Description: The SQL `UPDATE` statement is used to modify
existing records in a table.
- Significance in the Project: It allows users to update their data,
ensuring the accuracy and relevance of information in the Marriage
Bureau database.

8. DELETE Statement:
- Description: The SQL `DELETE` statement is used to remove
records from a table.
- Significance in the Project: This statement is employed in
functions like deleting user data, ensuring data hygiene and user
privacy.

9. Input Function (input()):


- Description: The `input()` function in Python is used to take user
input during runtime.
- Significance in the Project: It enables users to input their details,
preferences, and choices, making the project interactive and user-
friendly.

9
List of Functions:

1. `DataBaseCreation`
2. `TablesCreation`
3. `testing`
4. `add_user_details`
5. `add_match`
6. `update_data`
7. `search_data`
8. `delete_user_data`
9. `get_table_names`
10. `display_data`
11. `main_menu`

List of Tables:
1. `LoginDetails`
2. `CareerProfile`
3. `PersonalDetails`
4. `PreferenceDetails`
5. `Matches`

List of Variable Types:


1. `Full_Name` - String
2. `password` - String
3. `mydb` - Connection Object
4. `cursor` - Cursor Object
5. `Name` - List of Strings
6. Various input variables (e.g., `email`, `phone_number`, `password`,
`full_name`, etc.) - String
7. `annual_income` - Float
8. `age`, `height`, `min_age`, `max_age`, `user_id`, `partner_id`, etc. -
Integer
9. Various table names (e.g., `selected_table`, `selected_column`,
`primary_key_column`, etc.) - String
10. `current_data` - Tuple
11. `update_value` - String

10
12. `results` - List of Tuples
SQL Data Types:

1. LoginDetails Table:
- `UserId` - INT(5)
- `Email` - VARCHAR(255)
- `PhoneNumber` - VARCHAR(20)
- `Password` - VARCHAR(255)
- `FullName` - VARCHAR(255)

2. CareerProfile Table:
- `UserId` - INT(5)
- `EducationalQualification` - VARCHAR(255)
- `Profession` - VARCHAR(255)
- `AnnualIncome` - DECIMAL(10, 2)
- `Location` - VARCHAR(255)
- `JobDescription` - TEXT

3. PersonalDetails Table:
- `UserId` - INT(5)
- `FirstName` - VARCHAR(255)
- `LastName` - VARCHAR(255)
- `Age` - INT
- `Gender` - VARCHAR(10)
- `Religion` - VARCHAR(255)
- `ZodiacSign` - VARCHAR(20)
- `Location` - VARCHAR(255)
- `Height` - INT
- `Description` - TEXT
- `Interests` - TEXT
- `MotherTongue` - VARCHAR(255)

4. PreferenceDetails Table:
- `UserId` - INT(5)
- `Religion` - VARCHAR(255)
- `MinAge` - INT
- `MaxAge` - INT

11
- `Location` - VARCHAR(255)
- `Profession` - VARCHAR(255)
- `EducationalQualification` - VARCHAR(255)
- `ZodiacSign` - VARCHAR(20)

5. Matches Table:
- `MatchId` - INT(5)
- `UserId` - INT(5)
- `PartnerID` - INT(5)
- `Status` - VARCHAR(50)
- `DateOfMatch` - DATE

CODE & OUTPUT:


MainProgram.py

import mysql.connector as mysql


mydb = mysql.connect(host="localhost", user="root",
passwd='tiger')
cursor = mydb.cursor()
cursor.execute("CREATE DATABASE IF NOT EXISTS
MarriageBureau")
print("Created Database Successfully")
cursor.execute("use MarriageBureau")
cursor.execute("""
CREATE TABLE IF NOT EXISTS LoginDetails (
UserId INT(5) PRIMARY KEY
AUTO_INCREMENT,
Email VARCHAR(255) UNIQUE NOT NULL,
PhoneNumber VARCHAR(20) UNIQUE NOT
NULL,
Password VARCHAR(255) NOT NULL,
FullName VARCHAR(255) NOT NULL
)
""")
cursor.execute("""
CREATE TABLE IF NOT EXISTS CareerProfile
(
UserId INT(5) PRIMARY KEY,

12
EducationalQualification
VARCHAR(255),
Profession VARCHAR(255),
AnnualIncome DECIMAL(10, 2),
Location VARCHAR(255),
JobDescription TEXT,
FOREIGN KEY (UserId) REFERENCES
LoginDetails(UserId)
)
""")
cursor.execute("""
CREATE TABLE IF NOT EXISTS
PersonalDetails (
UserId INT(5) PRIMARY KEY,
FirstName VARCHAR(255) NOT NULL,
LastName VARCHAR(255) NOT NULL,
Age INT,
Gender VARCHAR(10),
Religion VARCHAR(255),
ZodiacSign VARCHAR(20),
Location VARCHAR(255),
Height INT,
Description TEXT,
Interests TEXT,
MotherTongue VARCHAR(255),
FOREIGN KEY (UserId) REFERENCES
LoginDetails(UserId)
)
""")
# PreferenceDetails Table
cursor.execute("""
CREATE TABLE IF NOT EXISTS
PreferenceDetails (
UserId INT(5) PRIMARY KEY,
Religion VARCHAR(255),
MinAge INT,
MaxAge INT,
Location VARCHAR(255),
Profession VARCHAR(255),
EducationalQualification
VARCHAR(255),
ZodiacSign VARCHAR(20),

13
FOREIGN KEY (UserId) REFERENCES
LoginDetails(UserId)
)
""")

# Matches Table
cursor.execute("""
CREATE TABLE IF NOT EXISTS Matches (
MatchId INT(5) PRIMARY KEY
AUTO_INCREMENT,
UserId INT(5),
PartnerID INT(5),
Status VARCHAR(50),
DateOfMatch DATE,
FOREIGN KEY (UserId) REFERENCES
LoginDetails(UserId),
FOREIGN KEY (PartnerID) REFERENCES
PersonalDetails(UserId)
)
""")

print("Required Tables Created")


'''password = input("Enter your MySQL password:")
mydb = mysql.connect(host="localhost", user="root",
passwd=f"{password}", database="MarriageBureau")
cursor = mydb.cursor()'''
def add_user_details():
try:
print("You Will be asked to Enter the Details
for Login: \n")
email = input("Enter Email:")
phone_number = input("Enter Phone Number:")
password = input("Enter Password:")
full_name = input("Enter Full Name:")

cursor.execute(f"""
INSERT INTO LoginDetails (Email,
PhoneNumber, Password, FullName)
VALUES ('{email}', '{phone_number}',
'{password}', '{full_name}')
""")
mydb.commit()

14
print("LoginDetails Added Successfully. \n")
print("\nNow You will be asked to Enter
Details for your Career Description: \n")

user_id = cursor.lastrowid # To Get the last


inserted user ID
educational_qualification = input("Enter
Educational Qualification:")
profession = input("Enter Profession:")
annual_income = float(input("Enter Annual
Income:"))
location = input("Enter Location:")
job_description = input("Enter Job
Description:")

cursor.execute(f"""
INSERT INTO CareerProfile
VALUES ({user_id},
'{educational_qualification}', '{profession}',
{annual_income},
'{location}',
'{job_description}')
""")
mydb.commit()
print("\nCareerProfile Added Successfully.\
n")
print("\nNow you will be asked to enter your
Personal Details.\n")

first_name = input("Enter First Name:")


last_name = input("Enter Last Name:")
age = int(input("Enter Age:"))
gender = input("Enter Gender:")
religion = input("Enter Religion:")
zodiac_sign = input("Enter Zodiac Sign:")
location = input("Enter Location:")
height = int(input("Enter Height:"))
description = input("Enter Description:")
interests = input("Enter Interests:")
mother_tongue = input("Enter Mother Tongue:")

cursor.execute(f"""
INSERT INTO PersonalDetails
15
VALUES ({user_id}, '{first_name}',
'{last_name}', {age}, '{gender}', '{religion}',
'{zodiac_sign}', '{location}',
{height},
'{description}', '{interests}',
'{mother_tongue}')
""")
mydb.commit()
print("\nPersonalDetails Added Successfully.\
n")
print("\nYour Profile is Created !\nNow you
will be asked to Enter the Details for your
Preferences! .\n")

religion = input("Enter Religion:")


min_age = int(input("Enter Minimum Age:"))
max_age = int(input("Enter Maximum Age:"))
location = input("Enter Location:")
profession = input("Enter Profession:")
educational_qualification = input("Enter
Educational Qualification:")
zodiac_sign = input("Enter Zodiac Sign:")

cursor.execute(f"""
INSERT INTO PreferenceDetails
VALUES ({user_id}, '{religion}',
{min_age}, {max_age}, '{location}',
'{profession}',
'{educational_qualification}', '{zodiac_sign}')
""")
mydb.commit()
print("\nPreferenceDetails Added
Successfully.!!\n")

except Exception as e:
print(f"\n\nFailed to Add User Details.
Error: {e}")

def add_match():
try:
user_id = int(input("Enter User ID:"))
partner_id = int(input("Enter Partner ID:"))
status = input("Enter Status:")
16
date_of_match = input("Enter Date of Match
(YYYYMMDD):")

cursor.execute(f"""
INSERT INTO Matches
VALUES (NULL, {user_id}, {partner_id},
'{status}', '{date_of_match}')
""")
mydb.commit()
print("\nMatches Added Successfully.\n")
except Exception as e:
print(f"\n\nFailed to Add Matches. Error:
{e}")

def update_data():
try:
# Display available tables
table_names = get_table_names() # A function
to Get a type list of the Names of All the Tables
from the Schema
print("Available tables:")

for i, table_name in enumerate(table_names,


1): # This Changes the Printed Index from 0 to 1.
print(f"{i}. {table_name}")

# Choose a table to update


choice = int(input("\nEnter the number
corresponding to the table to update data:"))
selected_table = table_names[choice - 1] #
Selects the Table from the table List

# Fetch Column Names


cursor.execute(f"DESCRIBE {selected_table}")
# To get the information about our table

columns = cursor.fetchall()
column_names = [column[0] for column in
columns] # 0th Column of Every Row is Being Fetched

17
# Exclude User ID from the list of columns as
User Id should not be updated by a User
column_names_exclude_id = [name for name in
column_names if name.lower() != 'userid']

# Display column names excluding User ID


print("Columns:")
for i, column_name in
enumerate(column_names_exclude_id, 1):
print(f"{i}. {column_name}")

# Choose a column to update


column_choice = int(input("Enter the number
corresponding to the column to update: "))
selected_column =
column_names_exclude_id[column_choice - 1]

# Ask for User ID to update


user_id = int(input("Enter User ID to
update:"))

# Display current data for reference


cursor.execute(f"SELECT * FROM
{selected_table} WHERE UserId={user_id}")
current_data = cursor.fetchone() # Only one
row is fetched using Fetchone
print(f"\nCurrent {selected_table} data for
User ID {user_id}: {current_data}")

# Collect updated data


update_value = input(f"\nEnter new value for
{selected_column}: ")

# Build and execute the update query


update_query = f"UPDATE {selected_table} SET
{selected_column}='{update_value}' WHERE
UserId={user_id}"
cursor.execute(update_query)
mydb.commit()
print(f"\n{selected_table} data updated
successfully for User ID {user_id}.")

except Exception as e:
18
print(f"Failed to update data. Error: {e}")

def search_data():
try:
print("Search Options:")
print("1. Search by UserId")
print("2. Search by First Name")

search_option = input("Enter your choice (1


or 2): ")

if search_option == '1':
primary_key_column = "UserId"
primary_key_value = int(input(f"Enter
{primary_key_column} to search:"))
elif search_option == '2':
primary_key_column = "FirstName" #
Assuming the column name is FirstName in the
PersonalDetails table
primary_key_value = input(f"Enter
{primary_key_column} to search:")
else:
print("Invalid choice. Please enter
either 1 or 2.")
return

cursor.execute(f"DESCRIBE PersonalDetails")
columns = cursor.fetchall()
column_names = [column[0] for column in
columns]

cursor.execute(f"SELECT * FROM
PersonalDetails WHERE
{primary_key_column}='{primary_key_value}'")
results = cursor.fetchall()
if results:
print(f"\nSearch results for
{primary_key_column}={primary_key_value}:\n")

border = "+" + "-" * 30 + "+"


19
# Display each row on a new line
for row in results:
print("\n" + "-" * 50) # Separate each
row with a line of dashes

# Display each column on a new line


for column_name, value in
zip(column_names, row):
print(f"{column_name}: {value}")

print() # Add an extra newline at the


end

else:
print(f"No results found for
{primary_key_column}={primary_key_value}")

except Exception as e:
print(f"Failed to search data. Error: {e}")

def delete_user_data(user_id):
try:
# Delete data from Matches table
cursor.execute(f"DELETE FROM Matches WHERE
UserId={user_id} OR PartnerID={user_id}")
mydb.commit()

# Delete data from PreferenceDetails table


cursor.execute(f"DELETE FROM
PreferenceDetails WHERE UserId={user_id}")
mydb.commit()

# Delete data from PersonalDetails table


cursor.execute(f"DELETE FROM PersonalDetails
WHERE UserId={user_id}")
mydb.commit()

20
# Delete data from CareerProfile table
cursor.execute(f"DELETE FROM CareerProfile
WHERE UserId={user_id}")
mydb.commit()

# Delete data from LoginDetails table


cursor.execute(f"DELETE FROM LoginDetails
WHERE UserId={user_id}")
mydb.commit()

print(f"All data for UserId {user_id} deleted


successfully.")
except Exception as e:
print(f"Failed to delete data. Error: {e}")

def get_table_names():
cursor.execute("SHOW TABLES")
tables = cursor.fetchall()
table_names = [table[0] for table in tables]
table_names = [table_name for table_name in
table_names if table_name != 'logindetails'] #
Exclude LoginDetails table
return table_names

def display_data():
try:
table_names = get_table_names()
print("Available tables:")
for i, table_name in enumerate(table_names,
1):
print(f"{i}. {table_name}")

choice = int(input("Enter the number


corresponding to the table to display data: "))
selected_table = table_names[choice - 1]

# Get column names


if selected_table != 'LoginDetails': #
Exclude LoginDetails table

21
cursor.execute(f"DESCRIBE
{selected_table}")
columns = cursor.fetchall()
column_names = [column[0] for column in
columns]

# Display column names


print("\nColumn Names:")
print(" | ".join(column_names))
print("-" * 30)

# Display data
cursor.execute(f"SELECT * FROM
{selected_table}")
results = cursor.fetchall()
for row in results:
print(" | ".join(map(str, row)))
print("-" * 30)
else:
print("LoginDetails table cannot be
displayed.")
except Exception as e:
print(f"Unable to fetch data. Error: {e}")
def main_menu():
while True:
print("\nMain Menu:")
print("1. Add User Details")
print("2. Add Match")
print("3. Display Data")
print("4. Update Data")
print("5. Search Data")
print("6. Delete Data")
print("7. Exit")

choice = input("Enter your choice (1-7): ")

if choice == '1':
add_user_details()
elif choice == '2':
add_match()
elif choice == '3':
display_data()

22
elif choice == '4':
update_data()
elif choice == '5':
search_data()
elif choice == '6':
user_id_to_delete = int(input("Enter User
ID to delete all associated data: "))
delete_user_data(user_id_to_delete)
elif choice == '7':
break
else:
print("Invalid choice. Please enter a
number between 1 and 7.")
main_menu()

23
24
25
DISPLAY

UPDATE

26
SEARCH

DELETE

27

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy