Marriage Bureau Management System in Python

This project is a simplified version of a Marriage Bureau Management System in Python, and it covers the basics of working with a MySQL database. Let’s break it down into key components:

  1. Database Setup:
  • A database is like a structured Excel sheet that stores information. In this project, we use MySQL, a popular database system.
  • We set up a database called “marriage_bureau_management” to store information about users and customers looking for marriage partners.
  1. User Registration and Login:
  • Users (people looking for marriage partners) can register with a username and password. This information is stored in the “user_id” table.
  • Users can log in using their registered username and password. If they provide the correct details, they can access the system.
  1. Customer Details:
  • Users can add details about people who are looking for marriage partners. This includes their name, address, caste, appearance, age, profession, and phone number.
  • This information is stored in the “customer_details” table.
  1. Searching for Matches:
  • Users can search for potential matches based on two criteria: profession and appearance.
  • If you’re looking for someone with a specific job (like a doctor or engineer), you can search for matches by their profession.
  • If you’re looking for someone who looks a certain way (beautiful, handsome, etc.), you can search for matches by their appearance.
  • The system will display matching profiles based on the criteria you provide.
  1. Menu and Interaction:
  • The project provides a simple menu for users with options like registration, login, adding customer details, and searching for matches.
  • Users can choose from these options and interact with the system.
  1. Error Handling:
  • The project includes some basic error handling to check for duplicate user registrations and provides feedback to the user.
  1. Database Interaction:
  • The program interacts with the MySQL database using Python. It uses SQL queries to store and retrieve data.
  1. Structure:
  • The code is organized into functions, which makes it easier to understand and maintain. Functions like “register_user” and “login_user” handle specific tasks.

This project is a simplified example of a larger system that a marriage bureau might use to manage profiles and match potential partners. It’s designed to help students learn the basics of database interaction, user authentication, and data retrieval.

Students can explore and expand on this project by adding more features, improving the user interface, and enhancing the database structure to make it more practical and robust.

 

Marriage Bureau Management System in Python Source Code:

import mysql.connector as sql

# Connect to the MySQL database
conn = sql.connect(host='localhost', user='root', password='admin')

c1 = conn.cursor()
c1.execute(" create database if not exists marriage_bureau_management")
c1.execute("use marriage_bureau_management")

def create_tables():
    # Create tables for customer details and user accounts
    c1.execute('''
        CREATE TABLE IF NOT EXISTS user_id (
            id INT AUTO_INCREMENT PRIMARY KEY,
            user_name VARCHAR(255),
            password VARCHAR(255)
        )
    ''')

    c1.execute('''
        CREATE TABLE IF NOT EXISTS customer_details (
            id INT AUTO_INCREMENT PRIMARY KEY,
            name VARCHAR(200),
            address VARCHAR(100),
            caste VARCHAR(100),
            appearance VARCHAR(100),
            age INT,
            profession VARCHAR(255),
            phone_no BIGINT
        )
    ''')

    conn.commit()

def register_user():
    name = input('Enter your Username: ')
    passwd = input('Enter your Password (only numbers): ')

    # Insert user data into the 'user_id' table using a parameterized query
    sql_insert = "INSERT INTO user_id (user_name, password) VALUES (%s, %s)"
    user_data = (name, passwd)

    try:
        c1.execute(sql_insert, user_data)
        conn.commit()
        print('User created successfully')
    except sql.IntegrityError as e:
        print('User already exists.')

def login_user():
    name = input('Enter your Username: ')
    passwd = input('Enter your Password: ')

    # Select user data from the 'user_id' table using a parameterized query
    sql_select = "SELECT * FROM user_id WHERE user_name = %s AND password = %s"
    user_data = (name, passwd)

    c1.execute(sql_select, user_data)
    result = c1.fetchone()

    if result:
        print('Login successful')
        return result[0]  # Return the user's ID
    else:
        print('Invalid username or password')
        return None

def add_customer_details():
    name = input('Enter the name: ')
    address = input('Enter the address: ')
    caste = input('Enter the caste: ')
    appearance = input('Enter the appearance: ')
    age = int(input('Enter the age: '))
    profession = input('Enter the profession: ')
    phone_no = int(input('Enter the phone number: '))

    # Insert customer data into the 'customer_details' table using a parameterized query
    sql_insert = "INSERT INTO customer_details (name, address, caste, appearance, age, profession, phone_no) VALUES (%s, %s, %s, %s, %s, %s, %s)"
    customer_data = (name, address, caste, appearance, age, profession, phone_no)

    try:
        c1.execute(sql_insert, customer_data)
        conn.commit()
        print('Customer details added successfully')
    except Exception as e:
        print('Error:', e)

def search_matches_by_profession(profession):
    # Select customer data from the 'customer_details' table based on the profession
    sql_select = "SELECT * FROM customer_details WHERE profession = %s"
    c1.execute(sql_select, (profession,))
    results = c1.fetchall()

    if results:
        print("Matching customers:")
        for result in results:
            print(result)
    else:
        print('No matching customers found.')

def search_matches_by_appearance(appearance):
    # Select customer data from the 'customer_details' table based on appearance
    sql_select = "SELECT * FROM customer_details WHERE appearance = %s"
    c1.execute(sql_select, (appearance,))
    results = c1.fetchall()

    if results:
        print("Matching customers:")
        for result in results:
            print(result)
    else:
        print('No matching customers found.')

def main_menu():
    print('*****************************************************MARRIAGE BUREAU MANAGEMENT**************************************************')
    print('1. Register')
    print('2. Login')
    print('3. Add Customer Details')
    print('4. Search Matches by Profession')
    print('5. Search Matches by Appearance')
    print('6. Exit')

    while True:
        choice = int(input('Enter your choice:'))

        if choice == 1:
            register_user()
        elif choice == 2:
            user_id = login_user()
            if user_id is not None:
                # You can add more functionality for logged-in users here
                pass
        elif choice == 3:
            add_customer_details()
        elif choice == 4:
            profession = input('Enter the profession to search: ')
            search_matches_by_profession(profession)
        elif choice == 5:
            appearance = input('Enter the appearance to search: ')
            search_matches_by_appearance(appearance)
        elif choice == 6:
            print('Exiting the program')
            break
        else:
            print('Invalid choice')

if __name__ == '__main__':
    create_tables()
    main_menu()

 

 

Sample Output:

*****************************************************MARRIAGE BUREAU MANAGEMENT**************************************************
1. Register
2. Login
3. Add Customer Details
4. Search Matches by Profession
5. Search Matches by Appearance
6. Exit
Enter your choice: 1
Enter your Username: John
Enter your Password (only numbers): 12345
User created successfully

*****************************************************MARRIAGE BUREAU MANAGEMENT**************************************************
1. Register
2. Login
3. Add Customer Details
4. Search Matches by Profession
5. Search Matches by Appearance
6. Exit
Enter your choice: 2
Enter your Username: John
Enter your Password: 12345
Login successful

*****************************************************MARRIAGE BUREAU MANAGEMENT**************************************************
1. Register
2. Login
3. Add Customer Details
4. Search Matches by Profession
5. Search Matches by Appearance
6. Exit
Enter your choice: 3
Enter the name: Alice
Enter the address: 123 Main St
Enter the caste: XYZ
Enter the appearance: Beautiful
Enter the age: 28
Enter the profession: Engineer
Enter the phone number: 1234567890
Customer details added successfully

*****************************************************MARRIAGE BUREAU MANAGEMENT**************************************************
1. Register
2. Login
3. Add Customer Details
4. Search Matches by Profession
5. Search Matches by Appearance
6. Exit
Enter your choice: 4
Enter the profession to search: Engineer
Matching customers:
(2, 'Alice', '123 Main St', 'XYZ', 'Beautiful', 28, 'Engineer', 1234567890)

*****************************************************MARRIAGE BUREAU MANAGEMENT**************************************************
1. Register
2. Login
3. Add Customer Details
4. Search Matches by Profession
5. Search Matches by Appearance
6. Exit
Enter your choice: 5
Enter the appearance to search: Beautiful
Matching customers:
(2, 'Alice', '123 Main St', 'XYZ', 'Beautiful', 28, 'Engineer', 1234567890)

*****************************************************MARRIAGE BUREAU MANAGEMENT**************************************************
1. Register
2. Login
3. Add Customer Details
4. Search Matches by Profession
5. Search Matches by Appearance
6. Exit
Enter your choice: 6
Exiting the program



Copywrite © 2020-2024, CBSE Python,
All Rights Reserved