Relative Content

Tag Archive for pythonpostgresqlsqlalchemyfastapi

Handling timezone aware objects in SQLAlchemy with FastAPI

Whenever I query a column representing a timestamp with timezone data, it returns a UTC datetime. Even when I update the timezone of the session with SET TIMEZONE <>, the output remains in UTC. I have a scenario in my FastAPI application where I need to dynamically change the timezone of the session based on the end user’s location. I use postgreSQL as my database.

Filtering JSON Field in PostgreSQL with SQLAlchemy

I’m working with a PostgreSQL database using SQLAlchemy in fastAPI, and I need to filter results based on a value in a JSON array column. However, I’m encountering an issue where the filter does not work as expected.

SQLAlchemy keeps joining a 3rd table

I am following the fastapi course from freecodecamp(https://www.youtube.com/watch?v=0sOvCWFmrtA). I am trying to join 2 tables, Vote and Post. The model for vote:-