我想在熊貓數據幀寫一些數據之前刪除表(如果存在):當我沒有表對象時,如何在SQLAlchemy中刪除表?
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()
的SQLAlchemy的文檔都指向一個Table.drop()
對象 - 我將如何創建對象,或等價有另一種方法來放棄這個表?
注意:我不能只使用if_exists = 'replace'
作爲輸入數據實際上是我遍歷DataFrames的字典 - 我已經壓抑了透明度(我希望)代碼。