Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix SQLAlchemy support with ORM #30

Merged
merged 3 commits into from Feb 12, 2019
Merged

Fix SQLAlchemy support with ORM #30

merged 3 commits into from Feb 12, 2019

Conversation

tiangolo
Copy link
Owner

@tiangolo tiangolo commented Feb 12, 2019

Fix SQLAlchemy support, including ORM. And update docs accordingly.

  • Update jsonable_encoder to support SQLAlchemy models by default, with a new sqlalchemy_safe parameter that checks for keys specific to SQLAlchemy.
  • Update tutorial for SQLAlchemy, update code and documentation.
  • Use a simple SQLite database for the tutorial, to make it very fast to replicate, while allowing to change a URL to switch to PostgreSQL (or others).
  • Add tests for SQLAlchemy tutorial code.
  • The new code example can be run as is (copy-paste-run), with a local SQLite database.

This is related to #4 (and it should fix it), might be related to #27 (as the current tutorial is broken). This new tutorial, fix and code should simplify starting with SQLAlchemy.

At some point, it could make sense to add (or replace) instructions for Starlette's integrated database utils, or the new https://github.com/encode/databases and PR #20.

Let's see how it all evolves. For now, this should work in a simple way, supporting SQLAlchemy ORM (that is not possible otherwise). This should also make it easier for people coming from mainstream frameworks like Flask and Django.

@codecov
Copy link

codecov bot commented Feb 12, 2019

Codecov Report

Merging #30 into master will not change coverage.
The diff coverage is 100%.

Impacted file tree graph

@@          Coverage Diff          @@
##           master    #30   +/-   ##
=====================================
  Coverage     100%   100%           
=====================================
  Files          95     97    +2     
  Lines        2502   2552   +50     
=====================================
+ Hits         2502   2552   +50
Impacted Files Coverage Δ
docs/src/sql_databases/tutorial001.py 100% <100%> (ø)
fastapi/encoders.py 100% <100%> (ø) ⬆️
...st_tutorial/test_sql_databases/test_tutorial001.py 100% <100%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 9484f93...621a6f6. Read the comment docs.

@tiangolo tiangolo merged commit 955e9fc into master Feb 12, 2019
@tiangolo tiangolo deleted the sqlalchemy branch February 12, 2019 19:02
@tiangolo tiangolo changed the title Update fix SQLAlchemy support with ORM Fix SQLAlchemy support with ORM Feb 12, 2019
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.

None yet

1 participant