updated to mysql-connector-python
This commit is contained in:
1 parent
65691a0aee
commit
4bc9b87317
6 files changed
+80
-68
No files matched your search
@@ -6,41 +6,41 @@ Tables 9.3–9.5 (STUDENT, GUARDIAN, ATTENDANCE).
|
||||
|
||||
## What it does on startup
|
||||
|
||||
1. Connects to the MySQL server at `10.0.1.40:3306`.
|
||||
1. Connects to the MySQL server at `10.10.0.160:3306`.
|
||||
2. Verifies the `student_db` database exists — creates it if not.
|
||||
3. Verifies the `GUARDIAN`, `STUDENT`, and `ATTENDANCE` tables exist
|
||||
(in that order, since STUDENT references GUARDIAN and ATTENDANCE
|
||||
references STUDENT) — creates any that are missing, with the exact
|
||||
data types and constraints from the schema (primary keys, foreign
|
||||
keys, `NOT NULL`, `UNIQUE` on `GPhone`, and the composite primary key
|
||||
`(AttendanceDate, RollNumber)` on ATTENDANCE).
|
||||
(in that order, since STUDENT references GUARDIAN and ATTENDANCE
|
||||
references STUDENT) — creates any that are missing, with the exact
|
||||
data types and constraints from the schema (primary keys, foreign
|
||||
keys, `NOT NULL`, `UNIQUE` on `GPhone`, and the composite primary key
|
||||
`(AttendanceDate, RollNumber)` on ATTENDANCE).
|
||||
4. Launches an interactive menu for Create / Read / Update / Delete.
|
||||
|
||||
## Setup
|
||||
|
||||
1. Install the one dependency:
|
||||
|
||||
```bash
|
||||
pip install -r requirements.txt
|
||||
```
|
||||
```bash
|
||||
pip install -r requirements.txt
|
||||
```
|
||||
|
||||
2. Set your MySQL credentials as environment variables (the host/port/
|
||||
database default to the assignment's values already):
|
||||
database default to the assignment's values already):
|
||||
|
||||
```bash
|
||||
export DB_USER=root
|
||||
export DB_PASSWORD=your_password_here
|
||||
# optional overrides — these already default correctly:
|
||||
# export DB_HOST=10.0.1.40
|
||||
# export DB_PORT=3306
|
||||
# export DB_NAME=student_db
|
||||
```
|
||||
```bash
|
||||
export DB_USER=root
|
||||
export DB_PASSWORD=your_password_here
|
||||
# optional overrides — these already default correctly:
|
||||
# export DB_HOST=10.10.0.160
|
||||
# export DB_PORT=3306
|
||||
# export DB_NAME=student_db
|
||||
```
|
||||
|
||||
3. Run it:
|
||||
|
||||
```bash
|
||||
python3 main.py
|
||||
```
|
||||
```bash
|
||||
python3 main.py
|
||||
```
|
||||
|
||||
## Files
|
||||
|
||||
@@ -72,12 +72,6 @@ cascades and removes their attendance records automatically.
|
||||
|
||||
## Notes
|
||||
|
||||
- Uses [PyMySQL](https://pymysql.readthedocs.io/), a pure-Python MySQL
|
||||
client — no system libraries (like `libmysqlclient`) required.
|
||||
- All input is validated against the schema's constraints (max lengths,
|
||||
digit counts, date format, P/A status) before hitting the database,
|
||||
and database-level errors (duplicate keys, foreign key violations)
|
||||
are caught and shown as friendly messages rather than crashing.
|
||||
- Tested end-to-end (connect → create DB/tables → full CRUD → constraint
|
||||
error handling → cascade delete) against a local MySQL/MariaDB
|
||||
instance before delivery.
|
||||
- Uses [mysql-connector-python](https://dev.mysql.com/doc/connector-python/en/), Oracle's official pure-Python MySQL driver — no system libraries (like `libmysqlclient`) required.
|
||||
- All input is validated against the schema's constraints (max lengths, digit counts, date format, P/A status) before hitting the database, and database-level errors (duplicate keys, foreign key violations) are caught and shown as friendly messages rather than crashing.
|
||||
- Tested end-to-end (connect → create DB/tables → full CRUD → constraint error handling → cascade delete) against a local MySQL/MariaDB instance before delivery.
|
||||
Reference in new issue
Block a user