Add SQLite database backend
Merge Request Summary
This merge request adds the SQLite database backend for the SpotIt project.
Changes Made
- Added
database.pyfor backend database operations. - Created SQLite database initialization logic.
- Added
reportstable schema. - Added functions to create, retrieve, update, and delete reports.
- Added report statistics functions for dashboard integration.
- Added
.gitignoreto prevent unnecessary files like database files, virtual environments, cache files, and uploads from being pushed.
Files Added
database.py.gitignore
Features Implemented
-
init_db()— Initializes the SQLite database. -
create_report()— Stores a new safety report. -
get_report()— Fetches a report using report ID. -
get_all_reports()— Retrieves all reports. -
update_status()— Updates report status. -
delete_report()— Deletes a report. -
get_report_stats()— Provides basic dashboard statistics. -
get_reports_by_category()— Provides category-wise report counts.
Testing Done
- Ran
python database.py. - Verified that the database initializes successfully.
- Confirmed that
spotit.dbis generated locally. - Ensured
spotit.dbis ignored using.gitignore.
Notes
The database file spotit.db is intentionally not pushed to the repository because it is generated locally during runtime.
Related Module
Member 2 — Database & Backend
Edited by Mansi Bhagyanagaram