Skip to main content

SQLAlchemy-Utc

https://badge.fury.io/py/SQLAlchemy-Utc.svg? https://travis-ci.com/spoqa/sqlalchemy-utc.svg?branch=master https://codecov.io/github/spoqa/sqlalchemy-utc/coverage.svg?branch=master

This package provides a drop-in replacement of SQLAlchemy’s built-in DateTime type with timezone=True option enabled. Although SQLAlchemy’s built-in DateTime type provides timezone=True option, since some vendors like SQLite and MySQL don’t provide timestamptz data type, the option doesn’t make any effect on these vendors.

UtcDateTime type is equivalent to the built-in DateTime with timezone=True option enabled on vendors that support timestamptz e.g. PostgreSQL, but on SQLite or MySQL, it shifts all datetime.datetime values to UTC offset before store them, and returns always aware datetime.datetime values through result sets.

Long story short, UtcDateTime does:

  • take only aware datetime.datetime,

  • return only aware datetime.datetime,

  • never take or return naive datetime.datetime,

  • ensure timestamps in database always to be encoded in UTC, and

  • work as you’d expect.

A SQLAlchemy helper function, utcnow(), is provided as an alternative to func.now() for generating UtcDateTime values on the server. For example: Column('time', UtcDateTime(), default=utcnow()).

Written by Hong Minhee at Spoqa, and distributed under MIT license.

Changelog

0.14.0

Released on September 24, 2021.

  • Add cache_ok flag on UtcDateTime to supress Pandas warnings. [#14 by derekderie]

0.13.0

Released on September 24, 2021.

  • Add milliseconds to SQLite datetimes. [#12 by Giovanni Santini]

  • Add support for newer python versions. (3.7, 3.8, 3.9) [#12 by Giovanni Santini]

0.12.0

Released on May 7, 2021.

  • Add py.typed file to the package to be compatible with PEP-561. [#10 by Dima Boger]

0.11.0

Released on November 13, 2020.

  • Ensured always returning the datetime with UTC timezone. [#8 by Eduard Christian Dumitrescu]

0.10.0

Released on January 25, 2018.

  • Dropped support of older Python versions: 2.6, 3.2, and 3.3. [#2 by George Leslie-Waksman]

  • Added sqlalchemy_utc.utcnow() function as an alternative to sqlalchemy.sql.functions.now() for generating UtcDateTime values on the database server. [#4 by George Leslie-Waksman]

0.9.0

First version. Released on June 22, 2016.

Release files for SQLAlchemy-Utc 0.14.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for SQLAlchemy-Utc 0.14.0
File Size Uploaded
SQLAlchemy-Utc-0.14.0.tar.gz 5.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for SQLAlchemy-Utc 0.14.0
File Interpreter ABI Platform
SQLAlchemy_Utc-0.14.0-py2.py3-none-any.whl Python 2, Python 3 none any Details

Total release size: 11.3 kB

Release files / SQLAlchemy-Utc-0.14.0.tar.gz

Download URL SQLAlchemy-Utc-0.14.0.tar.gz
Size 5.4 kB
Tags Source
SHA-256 checksum
How to use checksums
8e041624595b66d7b1d5ea8b6de486df5c1b9352697f3b24f862f0ded56cd7aa
BLAKE2b-256 checksum
How to use checksums
5cdb2d8f421cece2758954278bd16e05e3f73ce86c0062577a1ccfd3eb4208cd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.1 importlib_metadata/3.10.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.5

Release files / SQLAlchemy_Utc-0.14.0-py2.py3-none-any.whl

Download URL SQLAlchemy_Utc-0.14.0-py2.py3-none-any.whl
Size 6.0 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
d2379eed5cce372128b5e744ce382decd262b2c742ab31f7f22ca11c6647f60b
BLAKE2b-256 checksum
How to use checksums
e789ccfe4b579784f852c64f0fcb127e560990c2d75a2514dda51a9c87fb3782
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.1 importlib_metadata/3.10.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.5

Release history Release notifications | RSS feed

This release

0.14.0 This release

2 release files

0.13.0

2 release files

0.11.0

2 release files

0.10.0

2 release files

0.9.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page