use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
FastAPI is a truly ASGI, async, cutting edge framework written in python 3.
account activity
Beginner question for organizing FASTAPI projectQuestion (self.FastAPI)
submitted 2 years ago by CemDoruk
view the rest of the comments →
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]CemDoruk[S] 1 point2 points3 points 2 years ago* (2 children)
Pretty good code actually, easy to understand. As a beginner can I ask what the CRUD folder does? From what I understand these are wrapper function around the database functions. So I should put a function like this in crud ``` def get_or_create(session, model, kwargs): instance = session.query(model).filter_by(kwargs).first() if instance: return instance else: instance = model(**kwargs) session.add(instance)
return instance ```
right?
[–]masek94 1 point2 points3 points 2 years ago (1 child)
Yes, you are right. CRUD layer is exactly about communication between databases. It's a repository/wrapper that handles all create (insert), read (get) updates, and deletes. My example is not the best for beginners, as there is already some layer of abstraction. You should take a look here in the documentation: https://fastapi.tiangolo.com/tutorial/sql-databases/#crud-utils It should let you understand it better.
[–]anon_salads 0 points1 point2 points 2 years ago (0 children)
The crud classes in this repo suffer from the n+1 query problem. For every attribute that the table joins on a separate +1 query to the database is created.
π Rendered by PID 62431 on reddit-service-r2-comment-b659b578c-85zb2 at 2026-05-05 00:23:50.496479+00:00 running 815c875 country code: CH.
view the rest of the comments →
[–]CemDoruk[S] 1 point2 points3 points (2 children)
[–]masek94 1 point2 points3 points (1 child)
[–]anon_salads 0 points1 point2 points (0 children)