我想在Pandas数据帧中写入一些数据之前删除一个表(如果存在):
def store_sqlite(in_data, dbpath = 'my.db', table = 'mytab'):
database = sqlalchemy.create_engine('sqlite:///' + dbpath)
## DROP TABLE HERE
in_data.to_sql(name = table, con = database, if_exists = 'append')
database.close()
Run Code Online (Sandbox Code Playgroud)
SQLAlchemy文档都指向一个Table.drop()对象 - 我将如何创建该对象,或者等效地是否有另一种方法来删除该表?
注意:我不能只是使用,if_exists = 'replace'因为输入数据实际上是我循环的DataFrames的一个字典 - 为了清晰起见我已经压缩了代码(我希望).