Skip to content

feat: add SQLite schema and db.py for scan findings#14

Merged
ionfwsrijan merged 4 commits into
ionfwsrijan:mainfrom
khushboo-khatoon:feature/database-setup
Jun 1, 2026
Merged

feat: add SQLite schema and db.py for scan findings#14
ionfwsrijan merged 4 commits into
ionfwsrijan:mainfrom
khushboo-khatoon:feature/database-setup

Conversation

@khushboo-khatoon
Copy link
Copy Markdown
Contributor

Closes #1

What this PR does

Adds persistent SQLite storage for scan findings. Creates backend/app/db.py with init_db() and get_db() functions, initializes the database on server startup, and documents the schema in backend/README.md.

Type of change

  • Bug fix
  • New feature
  • ML model / training pipeline
  • Refactor (no behaviour change)
  • Documentation
  • Tests only

ML tier (if applicable)

  • Tier 1 — Triage
  • Tier 2 — Predictive
  • Tier 3 — Autonomous
  • Not ML-related

Changes

Backend

  • Added backend/app/db.py with init_db() and get_db() using aiosqlite
  • Added @app.on_event("startup") in main.py to call init_db() on boot
  • Added backend/README.md with full schema documentation

New dependencies

  • aiosqlite — async SQLite driver for non-blocking DB access in FastAPI

Database / schema changes

  • New table: findings (id, job_id, rule_id, severity, category, file_path, line_number, cwe, scanner, message, created_at)
  • New table: jobs (job_id, project_name, scan_method, created_at)
  • patchpilot.db auto-created in backend/ on first server boot

Testing

Started server locally — patchpilot.db was created automatically in backend/ on first boot.

Checklist

  • Tested locally end-to-end
  • No new console.error or unhandled Python exceptions introduced
  • requirements.txt updated with aiosqlite

Anything reviewers should focus on

db.py implementation — especially get_db() and init_db() functions.

@khushboo-khatoon
Copy link
Copy Markdown
Contributor Author

Hey @ionfwsrijan,

u can review and merge the PR , if all are okay

Thank you for all your help throughout the process (:

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR introduces persistent SQLite storage for scan findings in the FastAPI backend by adding a database module, initializing schema creation on server startup, and documenting the schema.

Changes:

  • Added backend/app/db.py with SQLite schema initialization (init_db) and a database connection helper (get_db) using aiosqlite.
  • Initialized the database on API startup via a FastAPI startup hook in backend/app/main.py.
  • Documented the jobs and findings tables in backend/README.md.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 9 comments.

File Description
backend/app/db.py Adds SQLite path, schema initialization, and DB connection helper.
backend/app/main.py Calls init_db() on application startup.
backend/README.md Documents the SQLite schema and where the DB file is created.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread backend/app/db.py Outdated
Comment thread backend/app/db.py
Comment thread backend/README.md Outdated
Comment thread backend/app/db.py Outdated
Comment thread backend/app/db.py
Comment thread backend/README.md Outdated
Comment thread backend/app/db.py Outdated
Comment thread backend/app/db.py
Comment thread backend/README.md Outdated
khushboo-khatoon and others added 2 commits June 1, 2026 14:23
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@ionfwsrijan
Copy link
Copy Markdown
Owner

@khushboo-khatoon Failing checks

@ionfwsrijan
Copy link
Copy Markdown
Owner

@khushboo-khatoon LGTM. Great work. Merging this now.

@ionfwsrijan ionfwsrijan merged commit 3438773 into ionfwsrijan:main Jun 1, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Design and initialize the SQLite schema for scan findings

3 participants