A Python application for managing student records in a PostgreSQL database with an interactive menu-driven interface.
-
Add Student: Insert new student records with the following details:
- First Name, Last Name
- Age, Address
- Email (Gmail)
- Gender, Semester
-
View Students: Display all student records from the database
-
Update Students: Modify existing student information (supports updating fname, lname, age, address, gmail, and semester)
- Python 3.x
- PostgreSQL database
psycopg2- PostgreSQL adapter for Pythonpython-dotenv- Load environment variables from .env file
-
Install required packages:
pip install psycopg2 python-dotenv
-
Create a
.envfile in the project root with your database credentials:DB_HOST=your_host DB_PORT=your_port DB_NAME=your_database DB_USER=your_username DB_PASSWORD=your_password
Run the application:
python main.py- Option 1: Add a new student (follow the prompts to enter student details)
- Option 2: View all students in the database
- Option 3: Exit the application
The application expects a students table with the following columns:
fname(VARCHAR)lname(VARCHAR)age(INTEGER)address(VARCHAR)gmail(VARCHAR)gender(VARCHAR)semester(VARCHAR)
- Ensure PostgreSQL server is running before starting the application
- Database credentials should be stored securely in the
.envfile (not committed to version control)