sqlalchemy不能放桌子

时间:2013-08-01 15:10:02

标签: python sqlalchemy

我创建我的表使用下一个代码:

class tableName(self._dbHelper.DeclarativeBase):
                __tablename__ = "tableName"
                if not tableEngine is None:
                    __table_args__ = {'mysql_engine' : tableEngine}
                first = Column(Integer, primary_key = True, autoincrement = True)
                second = Column(String(45))
                third = Column(String(100))

                def __init__(self, second = Utils.uniqID(), third = Utils.uniqID()):
                    self.second = second
                    self.third = third

但是后来我试图删除表,我得到一个错误,表示tableName不包含方法drop() 我怎么能放下这张桌子?

1 个答案:

答案 0 :(得分:10)

接下来是解决方案:

tableName.__table__.drop(self._engine)

详情请见Declarative doc