Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

sqlalchemy cannot drop table

I create my table use next code:

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

But then I'm trying to drop table, I got an error that tableName not contains method drop() How can I drop this table?

like image 255
Eugene Avatar asked Jul 19 '26 18:07

Eugene


1 Answers

The solution is next:

tableName.__table__.drop(self._engine)

More details are here: Declarative doc

like image 171
Eugene Avatar answered Jul 22 '26 08:07

Eugene



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!