嘿!
刚刚开始与Pylons一起使用sqlAlchemy,我的模型看起来像这样:
@H_301_10@刚刚开始与Pylons一起使用sqlAlchemy,我的模型看起来像这样:
from sqlalchemy import Column from sqlalchemy.types import Integer,String from helloworld.model.Meta import Base class Person(Base): __tablename__ = "person" id = Column(Integer,primary_key=True) name = Column(String(100)) email = Column(String(100)) def __init__(self,name='',email=''): self.name = name self.email = email def __repr__(self): return "<Person('%s')" % self.name
为了避免sqlite重用可能已被删除的id,我想将AUTOINCREMENT添加到列“id”.我查看了sqlalchemy的文档,看到可以发出sqlite_autoincrement.
给出该属性的示例可以是here.
sqlite_autoincrement似乎是在创建表本身时发出的,我只是想知道在使用模型的声明式样式时如何提供它.