spoqa / sqlalchemy-utc

SQLAlchemy type to store aware datetime values
https://pypi.python.org/pypi/SQLAlchemy-Utc
MIT License
101 stars 20 forks source link

Please document how to use the `mysql_sql_utcnow` functions #7

Open allardhoeve opened 5 years ago

allardhoeve commented 5 years ago

The functions in now.py look great! But I have no idea how to use them properly. Can you provide a snippet where you actually use them? Thanks!

dahlia commented 5 years ago

You can simply substitute existing sqlalchemy.sql.functions.now with sqlalchemy_utc.now.utcnow, e.g.:

from sqlalchemy_utc.now import utcnow

article = Article(title='…', content='…', published_at=utcnow())
gwax commented 5 years ago

You can also use them as server defaults: sa.Column('timestamp', sa.DateTime(True), server_default=utcnow())