This is a simple Python application that connects to a MySQL database and provides options to add, remove, and read student records.
- Python installed
- MySQL database server running
- Required Python libraries (
pymysql
) installed (install withpip install pymysql
)
- Open the script in your preferred Python environment.
- Ensure the MySQL server details (
host
,user
,password
,database
) are correct. - Run the script. It will prompt you with options.
- Follow the prompts to add, remove, or read student records.
connect_to_database()
: Establishes a connection to the MySQL database.add_student(conn, id, name, eno)
: Adds a new student record to the database.remove_student(conn, id)
: Removes a student record from the database.read_students(conn)
: Retrieves and prints all student records.main()
: Drives the application, providing user interaction.
- Ensure you have the necessary permissions to connect to the MySQL server and manipulate the database.