skillfed

SQLAlchemy-Utc

SQLAlchemy type to store aware datetime values

sqlalchemy-utc v0.14.0 198.0K downloads/30d#9,744 on PyPI103
Permissive license MIT License Abandoned released

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-utc

uv

uv add sqlalchemy-utc

poetry

poetry add sqlalchemy-utc

Installing 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

Development Status :: 4 - BetaIntended Audience :: DevelopersLicense :: OSI Approved :: MIT LicenseOperating System :: OS IndependentProgramming Language :: Python :: 2.7Programming Language :: Python :: 3.4Programming Language :: Python :: 3.5Programming Language :: Python :: 3.6Programming Language :: Python :: 3.7Programming Language :: Python :: 3.8Programming Language :: Python :: 3.9Programming Language :: Python :: Implementation :: CPythonProgramming Language :: Python :: Implementation :: PyPyProgramming Language :: Python :: Implementation :: StacklessProgramming Language :: SQLTopic :: Database :: Front-EndsTopic :: Software Development

Tags

sqlalchemy datetime timezoneutc datetime sqlalchemytimezone aware database columnsqlalchemy sqlite mysql utcdatabase datetime normalizationaware datetime sqlalchemy typecross-database timezone handling
timezone-handlingcross-databaseabandoned-but-stable

More Software Development packages