- main.py: Contains the program
- requirements.txt: contains the packages used
- readme.md: contains this readme.
This Python program requires several dependencies to be installed before it can be executed. Below are instructions on how to install these dependencies either through a requirements.txt
file or manually via pip.
Navigate to the Project Directory: Open a terminal or command prompt, unzip the project folder, and navigate to the directory where the project files are located.
- Install Dependencies:
Execute the following command in the terminal:
This command will automatically install all the required packages listed in the
pip install -r requirements.txt
requirements.txt
file.
If installing through requirements.txt
fails, you can manually install the required packages by pasting the following commands in your project terminal:
-
Install datetime:
pip install datetime
-
Install prettytable:
pip install prettytable
-
Install psycopg2:
pip install psycopg2
Once all the dependencies are installed, you can launch the program by executing the main Python file. Rhis can be done by running:
python main.py
In order to improve user experience, I implemented the following validation checks:
- Null check; None of the files can be null
- Check to see if the inputted email already exists in the database; email is unique
- Check to see if ID exists in the database (when trying to update and delete a user)
- Parse Date correctly
-
Upon launching the program, you will be prompted to input your database password. If the password is entered successfully, the project will be connect to your postgres database. Any of the default database credentials can be changed in
connection_to_db()
in main.py -
After connecting, the program will display that the table has been successfully created and initialized.
-
The main control menu will then appear. This control menu will call the appropriate CRUD methods bsaed on the user's input. The number correspond to the function, so in order to add a student to the table, the user has to click 1:
- 1 : add student
- 2 : update student's email
- 3 : delete student
- 4 : get all students
- 0 : exit
the user has input a valid first name, last name, email, and enrollment date. If all of the fields are valid, the student is added to the table
The user has to input a valid student id and a new unique email. If all of the inputs are valid, the student is updated
The user has to input a valid student id. If the id exists in the database, the student is deleted
Fetches all of the students in the students table, and displays then in a table format (using a python package called prettytable to display the table)
- After choosing to exit, the user can either enter 1 to drop the table, or 0 to not drop table.
- The program is terminated