Skip to content

Latest commit

 

History

1 Commit

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 

Repository files navigation

SQL + Python Integration — Employee HR Analysis

A data analysis project that connects Python to a MySQL database using mysql-connector-python, pulls employee data into a Pandas DataFrame, and performs HR analytics with Matplotlib visualizations.

Tech Stack

  • Python
  • MySQL + mysql-connector-python
  • Pandas
  • Matplotlib
  • python-dotenv (secure credentials)

Database Schema

Table: employees

Column Type Description
emp_id INT Primary key, auto increment
name VARCHAR(100) Employee name
department VARCHAR(50) Department name
salary INT Monthly salary
joining_date DATE Date of joining
is_active BOOLEAN Employment status

Analyses Performed

  • Average salary by department
  • Department-wise employee headcount
  • Salary range (max - min) per department
  • Active vs inactive employees
  • Employees who joined after 2021
  • Top 3 highest paid employees

Key Concepts Used

  • MySQL connection via mysql-connector-python
  • Secure credentials using .env + python-dotenv
  • SQL query execution from Python
  • Converting query results to Pandas DataFrame
  • .dt.year for datetime filtering
  • .agg() for multiple aggregations
  • Groupby, sort, filter operations

How to Run

  1. Clone the repo
  2. Install dependencies — run in terminal: pip install mysql-connector-python pandas matplotlib python-dotenv
  3. Create .env file in project root and add: DB_PASSWORD=yourpassword
  4. Run company_hr.sql in MySQL Workbench to set up the database
  5. Open and run analysis.ipynb top to bottom

Important

Never commit your .env file. It is listed in .gitignore.

About

MySQL + Python integration — connects to a company HR database, pulls employee data into Pandas, and performs salary and department analysis with Matplotlib visualizations.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages