This is a simple object-oriented Python project that simulates a bus trip management system using MySQL. The project allows you to add bus companies (firms), routes, trips, and individual trip times. It also provides a search functionality to find trips based on destination keywords.
Bus_Trip / └── pycache/ # Python cache files └──bus_trip │ └──pycache/ │ │ ├── create_obilet.py # Obilet class (database operations) │ │ ├── add_data_obilet.py
- **Python **
- MySQL (via XAMPP)
- mysql-connector-python library
- Install XAMPP and start MySQL server.
- Create a database named
bus_trip
in phpMyAdmin. - Create the following tables and relations inside the
obilet
database:
🧠 How the Code Works (Short Summary)
-
A class named is created to handle all database operations.
-
It connects to the MySQL database using the provided credentials.
-
add_firm, add_route, add_trips, and add_trip methods are used to insert data into their respective tables.
-
generate_trip_file allows users to search trips by destination and shows trip name, time, and firm.
-
At the end, several firms, routes, trips, and trip times are added, and the user is prompted to search for a trip.
📊 Database Schema
![Database Schema] (.\database.png)
CREATE TABLE firms (
Id INT AUTO_INCREMENT PRIMARY KEY,
firm_name VARCHAR(100)
);
CREATE TABLE routes (
Id INT AUTO_INCREMENT PRIMARY KEY,
route VARCHAR(255)
);
CREATE TABLE trips (
Id INT AUTO_INCREMENT PRIMARY KEY,
direction INT,
route_id INT,
trips_name VARCHAR(255),
FOREIGN KEY (route_id) REFERENCES routes(Id)
);
CREATE TABLE trip (
Id INT AUTO_INCREMENT PRIMARY KEY,
trips_id INT,
firm_id INT,
trip_time VARCHAR(10),
FOREIGN KEY (trips_id) REFERENCES trips(Id),
FOREIGN KEY (
firm_id) REFERENCES firms(Id)
);
---