Skip to main content

Convert to/from timezone aware datetimes when storing in a DBMS

Project description

Installation

pip install sqlalchemy-utcdatetime

Sample Usage

import sqlalchemy as sa
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy_utcdatetime import UTCDateTime
import datetime, pytz

Base = declarative_base()

class MyModel(Base):
    __tablename__ = 'my_model'

    id = sa.Column(sa.Integer(), primary_key=True)
    my_datetime = sa.Column(UTCDateTime())


m = MyModel()
m.my_datetime = datetime.datetime.now(pytz.timezone('Australia/Sydney'))

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

SQLAlchemy-UTCDateTime-1.0.4.tar.gz (2.4 kB view hashes)

Uploaded Source

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page