Lessons Learned: Handling DateTime Across Time Zones in Postgres with SQLAlchemy and Alembic
Working with date and time in a global application is tricky. When you throw in multiple time zones, daylight saving time (DST), and different database behaviors, things can get messy quickly. Here’s what I learned while working with Python, SQLAlchemy, Alembic, and PostgreSQL. Lesson 1 — Always Use TIMESTAMP WITH TIME ZONE in Postgres In PostgreSQL, there are two main timestamp types: Rule: Use timestamptz for anything that needs to