diff --git a/sqlalchemy_utils/types/arrow.py b/sqlalchemy_utils/types/arrow.py index 4394acc..0ce67bd 100644 --- a/sqlalchemy_utils/types/arrow.py +++ b/sqlalchemy_utils/types/arrow.py @@ -14,6 +14,43 @@ from .scalar_coercible import ScalarCoercible class ArrowType(types.TypeDecorator, ScalarCoercible): + """ + ArrowType provides way of saving Arrow_ objects into database. It + automatically changes Arrow_ objects to datatime objects on the way in and + datetime objects back to Arrow_ objects on the way out (when querying + database). ArrowType needs Arrow_ library installed. + + .. _Arrow: http://crsmithdev.com/arrow/ + + :: + + from datetime import datetime + from sqlalchemy_utils import ArrowType + import arrow + + + class Article(Base): + __tablename__ = 'article' + id = sa.Column(sa.Integer, primary_key=True) + name = sa.Column(sa.Unicode(255)) + created_at = sa.Column(ArrowType) + + + + article = Article(created_at=arrow.utcnow()) + + + As you may expect all the arrow goodies come available: + + :: + + + article.created_at = article.created_at.replace(hours=-1) + + article.created_at.humanize() + # 'an hour ago' + + """ impl = types.DateTime def __init__(self, *args, **kwargs):