LoginSignup
4

More than 3 years have passed since last update.

SQLAlchemyでTime型を保存する

Last updated at Posted at 2015-11-20

Time型を使って今の時間を保存するのは以下のコード

import datetime
from sqlalchemy import (Text, Time)
class Tel(Base):
    __tablename__ = 'tel'
    no = Column(Text)
    updated_at = Column(Time, default=datetime.datetime.now().time())

時間の扱い方が、こなれてない気がしてならない・・・

ここのページの「A type for 〜」見ると、SQLAlchemyの型とPythonの型のマッピングがわかる。

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4