Skip to content

Tag: sqlalchemy

How to save a calculated column in SQLAlchemy?

I would like to know how to save a calculated value in a clean way in the database: An example (taken from the SQLAlchemy manual): So length is calculated. But for easier query look-ups (in another database tool), I would like to have this length saved as well into the table. So my first crude test was to sim…

Delete sql table rows from python

I can successfully connect my python notebook with sql server this way : Let’s take this sample dataframe : I have a sql table with the same columns, named table_name. Objective : I want to delete in table_name all the rows where a row in df has the same Name, same Date, same Status, and Max = 0 (only i…

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 &#822…

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…