The user will be providing some information such as table_x with column_x. And I’d like to create these tables in an existing database or a new database based on the user’s value. These values will be provided during run-time therefore I cannot create the Model beforehand. If anyone could provide some help, let me know! Answer I’ve managed to figure
Tag: fastapi
Python and FastAPI: keep getting 405 when posting response
I have made at fasstapi at https://lectio-fastapi.herokuapp.com/docs#/ When I test on the fastapi site it works like a charm. But when I try to access it from another python program i get 405 when posting the output I am getting is: And I am expecting to get these returns: It seems like to me I need to define something more
How to stream DataFrame using FastAPI without saving the data to csv file?
I would like to know how to stream a DataFrame using FastAPI without having to save the DataFrame to a csv file on disk. Currently, what I managed to do is to stream data from the csv file, but the speed was not very fast compared to returning a FileResponse. The /option7 below is what I’m trying to do. My
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
FastAPI is very slow in returning a large amount of JSON data
I have a FastAPI GET endpoint that is returning a large amount of JSON data (~160,000 rows and 45 columns). Unsurprisingly, it is extremely slow to return the data using json.dumps(). I am first reading the data from a file using json.loads() and filtering it per the inputted parameters. Is there a faster way to return the data to the
In my List of multiple dictionaries only my last dictionary item save on database, I want to save all [closed]
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers. This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers. Closed 6 months ago. Improve this question
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:
How to exclude Optional unset values from a Pydantic model using FastAPI?
I have this model: So I want to be able to take requests like: and Right now in the second case I get using this code: So how can I exclude n_processes here? Answer You can use exclude_none param of Pydantic’s model.dict(…): Output: Also, it’s more idiomatic to write Optional[int] instead of Union[int, None].
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