Skip to content

Sync flask-connexion-rest-part-3 with the updated tutorial - #884

Open
realpython-bot wants to merge 1 commit into
masterfrom
maintenance/flask-connexion-rest-api-part-3-20261012
Open

realpython-bot wants to merge 1 commit into
masterfrom
maintenance/flask-connexion-rest-api-part-3-20261012

Conversation

@realpython-bot

Copy link
Copy Markdown
Collaborator

Maintenance update of Python REST APIs With Flask, Connexion, and SQLAlchemy – Part 3.

What changed

  • rp_flask_api/notes.py: replaced the legacy Note.query.get(note_id) and Person.query.get(person_id) calls with db.session.get(Note, note_id) and db.session.get(Person, person_id). Query.get() is a legacy construct since SQLAlchemy 2.0 and emits a LegacyAPIWarning on current Flask-SQLAlchemy. Session.get() works on the pinned SQLAlchemy 1.4 and on 2.x. The article's draft update makes the same change.

Article draft: https://realpython.com/pbjt/blog/post/2523/change/
Maintenance card: https://trello.com/c/7oKcpEtx

How it was verified

  • Fresh Python 3.11 venv with the folder's pinned requirements.txt.
  • Ran build_database.py on a copy of the folder, then drove the app through Flask's test client: GET /api/notes/1 (200), GET /api/notes/999 (404), PUT /api/notes/1 (201), POST /api/notes for an existing person (201) and a missing one (404), DELETE /api/notes/1 (204, then a 404 on re-read), GET /api/people (200), and GET / (200).
  • uvx ruff@0.14.1 format --check and uvx ruff@0.14.1 check on the folder both pass.

🤖 Generated with Claude Code

…n REST APIs With Flask, Connexion, and SQLAlchemy – Part 3

Replace the legacy Query.get() calls in notes.py with db.session.get().

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

This branch has not been deployed

No deployments
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.

1 participant