logo by @sawaratsuki1004

Project by Ram Chimnani

Freelancer Project Management System

Small Wonders Senior Secondary School

First Step

Set Up a Database

To manage freelancer projects effectively, the first step is to create a database and set up a table to store project details. Follow the steps below to create the necessary database and table using SQL:

Database.sql

CREATE DATABASE freelancer_db;

USE freelancer_db;

CREATE TABLE projects (
project_id INT AUTO_INCREMENT PRIMARY KEY,
name VARCHAR(255) NOT NULL,
client_name VARCHAR(255) NOT NULL,
status VARCHAR(50) NOT NULL DEFAULT 'Pending',
payment FLOAT NOT NULL DEFAULT 0.0
);

Preview of Projects Table

project_idnameclient_namestatuspayment
1Website DesignJohn DoePending500.0
2Mobile AppJane SmithCompleted1200.0

Connecting to the MySQL Database

&

Adding a New Project

This script defines two functions: one to connect to the MySQL database and another to add a new project record into a table.

fpms.py

import mysql.connector # Use 'pip install mysql-connector-python'

# Connect to MySQL
def connect_db():
return mysql.connector.connect(
host="localhost",
user="root",
password="password", # Replace with your MySQL root password
database="freelancer_db"
)

# Add Project
def add_project(name, client_name, payment):
conn = connect_db()
cursor = conn.cursor()
query = "INSERT INTO projects (name, client_name, payment) VALUES (%s, %s, %s)"
values = (name, client_name, payment)
cursor.execute(query, values)
conn.commit()
print("Project added successfully!")
conn.close()

| ID | Name       | Client Name   |Payment|
|----|------------|---------------|-------|
| 1  | Project A  | Client Alpha  | $500  |
| 2  | Project B  | Client Beta   | $1000 |
| 3  | Project C  | Client Gamma  | $1500 |
      

This Python code is used to interact with a MySQL database and perform operations related to a project management system. It contains two main functions: connecting to the database and adding a new project.

Project Management Functions

The Python code provides three key operations for the `projects` table:

1. View Projects : Fetch and display all project records.

2. Update Project : Modify `status` and `payment` for a specific project.

3. Delete Project : Remove a project by its `project_id`.

fpms.py

# View All Projects
def view_projects():
conn = connect_db()
cursor = conn.cursor()
query = "SELECT * FROM projects"
cursor.execute(query)
projects = cursor.fetchall()
print("Projects:")
for project in projects:
print(project)
conn.close()

# Update Project
def update_project(project_id, status, payment):
conn = connect_db()
cursor = conn.cursor()
query = "UPDATE projects SET status = %s, payment = %s WHERE project_id = %s"
values = (status, payment, project_id)
cursor.execute(query, values)
conn.commit()
print("Project updated successfully!")
conn.close()

# Delete Project
def delete_project(project_id):
conn = connect_db()
cursor = conn.cursor()
query = "DELETE FROM projects WHERE project_id = %s"
values = (project_id,)
cursor.execute(query, values)
conn.commit()
print("Project deleted successfully!")
conn.close()
ramchimnani.com/project.py

Project Manager

Manage your projects efficiently with the following actions.

View Projects

Click below to fetch and view all existing projects.

Update Project

Provide the project ID, new status, and payment to update the project.

Delete Project

Enter the project ID to delete the corresponding project.

Main Menu

The main entry point of the program, which displays a menu with five options and handles user inputs to execute corresponding actions.

fmps.py

# Main Menu
def main_menu():
while True:
print("
Freelancer Project Management")
print("1. Add Project")
print("2. View Projects")
print("3. Update Project")
print("4. Delete Project")
print("5. Exit")
choice = input("Enter your choice: ")

if choice == '1':
name = input("Enter project name: ")
client_name = input("Enter client name: ")
payment = float(input("Enter payment amount: "))
add_project(name, client_name, payment)
elif choice == '2':
view_projects()
elif choice == '3':
project_id = int(input("Enter project ID: "))
status = input("Enter project status: ")
payment = float(input("Enter updated payment amount: "))
update_project(project_id, status, payment)
elif choice == '4':
project_id = int(input("Enter project ID to delete: "))
delete_project(project_id)
elif choice == '5':
print("Exiting...")
break
else:
print("Invalid choice. Please try again.")

if __name__ == "__main__":
main_menu()
Command Prompt - fmps.py
Freelancer Project Management
  1. Add Project
  2. View Projects
  3. Update Project
  4. Delete Project
  5. Exit
  >> Enter your choice: 1
  
  Enter project name: >> Website Redesign
  Enter client name: >> Acme Corp
  Enter payment amount: >> 5000
  Project added successfully!
  
  Freelancer Project Management
  1. Add Project
  2. View Projects
  3. Update Project
  4. Delete Project
  5. Exit
  Enter your choice: >> 5
  
  Exiting...