Feat: Migrate Data Source from JSON to Relational Database (SQLAlchem…#1194
Open
desireddymohithreddy0925 wants to merge 3 commits into
Open
Conversation
…y) (komalharshita#1176) - Added Flask-SQLAlchemy to requirements - Created Project db.Model with db.JSON support - Wrote seed_db.py script to migrate JSON to SQLite - Refactored load_all_projects to query SQLite db - Updated test_basic.py to use temporary in-memory sqlite db
|
Someone is attempting to deploy a commit to the komalsony234-1530's projects Team on Vercel. A member of the Team first needs to authorize it. |
Owner
|
@desireddymohithreddy0925 kindly resolve the merge conflicts |
Author
|
@komalharshita done mam |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR resolves #1176 by migrating the DevPath data layer from a static
projects.jsonfile to an SQLite relational database viaFlask-SQLAlchemy. This lays the groundwork necessary to implement dynamic user-specific features like progress tracking, bookmarks, and upvoting without risking race conditions or data loss in flat files.Related Issue
Closes #1176
Type of Change
data/projects.jsonWhat Was Changed
requirements.txtFlask-SQLAlchemy==3.1.1as a core dependency.src/config.pySQLALCHEMY_DATABASE_URIconfiguration pointing todata/devpath.db.src/models.pyProjectSQLAlchemy model mapped to theprojectstable. Utilizeddb.JSONfor arrays (skills,features,roadmap, etc.) to match our existing data structure, alongside a.to_dict()helper method.src/app.pydbobject with the main Flask app context.src/seed_db.pyprojects.jsonand cleanly populates the new SQLite database.src/utils/data_loader.pyload_all_projectsandfind_project_by_idto directly query the database and serialize the results back into standard Python dictionaries, keeping the machine learning recommender completely intact.tests/test_basic.pysetup_module()to inject an in-memory SQLite database (sqlite:///<tmp>) within the test client's app context and populate it with our existing JSON file data before executing any of the 80 tests.How to Test This PR
git checkout feat/issue-1176-sqlalchemy-migrationpip install -r requirements.txtto grab the SQLAlchemy package.python src/seed_db.pyto perform the initial migration and generatedata/devpath.db.pytest tests/test_basic.pyand ensure all 80 tests pass without failures.python src/app.pyTest Results
Self-Review Checklist
feat/,fix/,docs/,data/,style/,test/pytest tests/test_basic.pyand all tests passflake8 .locally and there are no errorsprint()orconsole.log()debug statementsNotes for Reviewer
None.