SQLAlchemy-Utc
SQLAlchemy type to store aware datetime values
What it is and what it does
SQLAlchemy-Utc solves the problem of inconsistent timezone handling across different database backends. SQLAlchemy's built-in DateTime type with timezone support works well on databases like PostgreSQL that have native timestamptz types, but fails silently on SQLite and MySQL, which lack native timezone support. This package provides a drop-in UtcDateTime replacement that normalizes behavior: it accepts only aware datetime objects, converts them to UTC before storage, and always returns aware UTC datetimes from queries, regardless of the underlying database.
The package also includes a utcnow() helper function as a server-side alternative to func.now() for setting default timestamps. It's designed for applications that need consistent, predictable datetime handling across multiple database backends without manual UTC conversion logic in application code.
Use it for:
- Store event timestamps consistently across SQLite development and PostgreSQL production databases
- Ensure all datetime values in a multi-database application are UTC-normalized without application-level conversion
- Set server-side default timestamps using utcnow() that work identically on SQLite, MySQL, and PostgreSQL
- Build timezone-aware ORM models that return aware datetime objects from all query results
- Migrate applications from naive to timezone-aware datetimes while maintaining database compatibility
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Provides a SQLAlchemy DateTime type that consistently handles timezone-aware datetimes across database vendors, storing all values in UTC and returning aware datetime objects regardless of whether the underlying database supports native timezone types.
Yes, with conditions. The package solves a real cross-database datetime problem and has no security vulnerabilities. However, it is abandoned (last commit August 2022, no activity for nearly four years) and only explicitly supports Python up to 3.9. Install it if you need consistent UTC datetime handling across SQLite/MySQL and PostgreSQL and are willing to maintain it yourself or pin to a stable SQLAlchemy version; avoid it if you require active maintenance or support for the latest Python versions.
Install
sqlalchemy-utc on PyPI
pip
pip install sqlalchemy-utcuv
uv add sqlalchemy-utcpoetry
poetry add sqlalchemy-utcInstalling SQLAlchemy-Utc
Before you install
Low install friction with just two runtime dependencies (setuptools and SQLAlchemy). Package is abandoned as of August 2022 with no commits for nearly four years, though the repository remains public and the last release (0.14.0) added Pandas compatibility.
License in practice
MIT License permits free use, modification, and distribution with minimal restrictions, making it suitable for both open-source and commercial projects.
Quickstart
from sqlalchemy import Column, Integer, create_engine
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy_utc import UtcDateTime, utcnow
Base = declarative_base()
class Event(Base):
__tablename__ = 'events'
id = Column(Integer, primary_key=True)
created_at = Column(UtcDateTime(), default=utcnow())
Verify before relying
- Whether the package works reliably with current SQLAlchemy versions (last release was September 2021, no maintenance since)
- Compatibility with Python 3.10+ (classifiers only list up to 3.9)
- Whether millisecond precision on SQLite (added in 0.13.0) handles all edge cases correctly
Package facts
| License | MIT License (permissive) |
| Python support | not specified |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 2 — setuptools, SQLAlchemy |
| Maintenance | abandoned — 1,785 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 197,960/month — #9,744 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: SQLAlchemy_Utc-0.14.0-py2.py3-none-any.whl
Tags
More Software Development packages
Provides backported and experimental type hints…
permissive · top 100 on PyPI
numpyNumPy provides an N-dimensional array object…
permissive · top 100 on PyPI
fastapiFastAPI is a Python web framework for building…
permissive · top 100 on PyPI
annotated-docProvides a way to document function parameters,…
permissive · top 100 on PyPI
typerTyper builds command-line applications from…
permissive · top 1,000 on PyPI
distlibDistlib provides low-level packaging utilities…
permissive · top 1,000 on PyPI
wheneverWhenever provides type-safe, DST-aware datetime…
permissive · top 5,000 on PyPI
datetypeDateType provides type-checking-time wrapper…
unclear · top 15,000 on PyPI
SQLAlchemy-JSONFieldProvides a SQLAlchemy column type for storing…
permissive · top 5,000 on PyPI
pytzpytz brings the Olson timezone database into…
permissive · top 100 on PyPI
airporttimeConverts between local time and UTC for any…
unclear · top 15,000 on PyPI
backports.zoneinfoProvides IANA time zone support for Python…
permissive · top 5,000 on PyPI
timesTimes converts between universal (UTC) time and…
permissive · top 15,000 on PyPI
DateTimeProvides a DateTime data type for working with…
unclear · top 5,000 on PyPI
pendulumPendulum provides an enhanced datetime API for…
permissive · top 1,000 on PyPI
temporaProvides utilities, constants, and routines for…
permissive · top 5,000 on PyPI