SQLAlchemy の宣言型モデルで定義されたクラス オブジェクトと一致するように、データベース内のテーブルがいつ変更されるのか、私は混乱しています。
たとえば、commands
これらのフィールドを持つテーブルがあります
Command.__table__
Table('commands', MetaData(bind=None), Column('id', Integer(), table=<commands>, primary_key=True, nullable=False), Column('user_id', Integer(), ForeignKey('users.id'), table=<commands>), Column('command_title', String(length=50), table=<commands>), Column('command_desc', String(length=100), table=<commands>), Column('time_added', DateTime(), table=<commands>), Column('time_updated', DateTime(), table=<commands>), Column('favorite', Boolean(), table=<commands>), schema=None)
ただし、データベースに新しい行を追加しようとすると、SQL が文句を言います。favorite
これは、列を追加したばかりで、まだデータベースに反映されていないためだと思います。
エラー :
OperationalError: (OperationalError) table commands has no column named favorite u'INSERT INTO commands (user_id, command_title, command_desc, time_added, time_updated, favorite) VALUES (?, ?, ?, ?, ?, ?)' (2, u'HI', None, None, None, 1)