在 MySQL 中,我们可以使用AUTO_INCREMENT = ?
来自动插入一个主键值。我们如何在 SQLAlchemy/Alembic 中做到这一点?非常感谢!
问问题
526 次
1 回答
0
如果类型为“Integer, primary_key=True”,则在 CREATE TABLE 中发出 auto_increment。在使用 alter_column 的 Alembic 中,您需要将其指定为 alter_column。
参见 alter_column() 的“autoincrement”和“existing_autoincrement”:
https://alembic.readthedocs.org/en/latest/ops.html#alembic.operations.Operations.alter_column
请参阅 Column 的 autoincrement,注意这默认为 True 并且您通常不需要更改它,在:
http://docs.sqlalchemy.org/en/rel_0_7/core/schema.html#sqlalchemy.schema.Column.__init__
于 2012-10-25T16:25:39.543 回答