Skip to content
Advertisement

Tag: fastapi

Pydantic schema logic

So, I’m building an API to interact with my personal wine labels collections database. For what I understand, a pydantic model purpose is to serve as a “verifier” of the schema that is sent to the API. So, my pydantic schema for adding a label is the following: None of the fields is to be updated automatically. This is equal

Strawberry+FastAPI: How to get request-info in a dependency?

Consider this code: How do I get the request info in the dependencies custom_context_dependency and has_root_access? Answer When I tried FastAPI’s Request, it was still showing some error when Strawberry’s page was opened. Later I understood that the error was being raised by WebSocket connection. So my solution was to make request and web-socket optional params: Either request or websocket

How to union two counts queries in SQLAlchemy?

I have two queries and the only difference between then is that one is counting the success status and the other failure status. Is there a way to get this result in just one query? I’m using SQLALchemy to do the queries. Answer You can use conditions on Count, your query will look like:

Pydantic created at and updated at fields

I’m new to using Pydantic and I’m using it to set up the models for FastAPI to integrate with my postgres database. I want to make a model that has an updated_at and created_at field which store the last datetime the model was updated and the datetime the model was created. I figured created_at could be something like this: How

Advertisement