Skip to content
Advertisement

Tag: fastapi

asyncpg.exceptions.DataError: invalid input for query argument $1: 217027642536 (value out of int32 range)

I’m working on a project that uses FastAPI alongside Pydantic and SQLAlchemy. I’m also using encode/databases to manage database connections. But for some weird reason, I get asyncpg.exceptions.DataError: invalid input for query argument $1: 217027642536 (value out of int32 range) anytime I try saving to the database. Here’s what my code looks like: database.py database_manager.py endpoints.py models.py services.py I can’t

Write a CSV file asynchronously in Python

I am writing a CSV file with the following function: However, as there is no await allowed over writerows method, there are no rows being written into the CSV file. How to resolve this issue? Is there any workaround available? Thank you. Entire code can be found here. Answer In my opinion it’s better not to try to use the

Architecture Flask vs FastAPI

I have been tinkering around Flask and FastAPI to see how it acts as a server. One of the main things that I would like to know is how Flask and FastAPI deal with multiple requests from multiple clients. Especially when the code has efficiency issues (long database query time). So, I tried making a simple code to understand this

List of object attributes in pydantic model

I use Fast API to create a web service. There are following sqlAlchemy models: Pydantic schemas are below: What I have now is: What I want to achieve is to get user from api in following structure: Is that possible? How should I change schemas to get this? Answer If you are okay with handling the how to “get user

Partial update in FastAPI

I want to implement a put or patch request in FastAPI that supports partial update. The official documentation is really confusing and I can’t figure out how to do the request. (I don’t know that items is in the documentation since my data will be passed with request’s body, not a hard-coded dict). How can I complete my code to

Advertisement