- Notifications
You must be signed in to change notification settings - Fork20
SQLAlchemy type to store aware datetime values
License
spoqa/sqlalchemy-utc
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation
This package provides a drop-in replacement of SQLAlchemy's built-inDateTimetype withtimezone=True option enabled. Although SQLAlchemy's built-inDateTime type providestimezone=True option, since some vendors likeSQLite and MySQL don't providetimestamptz data type, the option doesn'tmake any effect on these vendors.
UtcDateTime type is equivalent to the built-inDateTime withtimezone=True option enabled on vendors that supporttimestamptze.g. PostgreSQL, but on SQLite or MySQL, it shifts alldatetime.datetimevalues to UTC offset before store them, and returns always awaredatetime.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 alternativetofunc.now() for generatingUtcDateTime values on the server. Forexample:Column('time', UtcDateTime(), default=utcnow()).
Written byHong Minhee atSpoqa, and distributed under MIT license.
About
SQLAlchemy type to store aware datetime values
Topics
Resources
License
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Packages0
Uh oh!
There was an error while loading.Please reload this page.
Contributors11
Uh oh!
There was an error while loading.Please reload this page.