Spaces:
Running
Running
Download storage/fetch_faculty.py from Urvikava/Faculty-Finder-api: direct link, hf CLI and curl.
- Browser
- Download file 587 Bytes
-
https://huggingface.co/spaces/Urvikava/Faculty-Finder-api/resolve/main/storage/fetch_faculty.py
- Command line
-
hf download hf://spaces/Urvikava/Faculty-Finder-api/storage/fetch_faculty.py
-
curl -L -o fetch_faculty.py https://huggingface.co/spaces/Urvikava/Faculty-Finder-api/resolve/main/storage/fetch_faculty.py
587 Bytes
| import sys | |
| import os | |
| sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))) | |
| from storage.db import get_connection | |
| def fetch_faculty_by_id(faculty_id: int): | |
| query = """ | |
| SELECT | |
| faculty_id, | |
| name, | |
| faculty_category, | |
| image_url, | |
| education, | |
| phone, | |
| email, | |
| address | |
| FROM faculty | |
| WHERE faculty_id = ? | |
| """ | |
| with get_connection() as conn: | |
| row = conn.execute(query, (faculty_id,)).fetchone() | |
| if row is None: | |
| return None | |
| return dict(row) |