我有一个带有产品名称和日期的数据框 我正在尝试从产品和日期匹配的数据库表中删除记录。 我不确定如何在where条件中使用datframe值来放置条件:
示例:
在这里,我只想根据上述值删除产品,并且我不想在2020年1月1日删除产品B。
目前,我正在使用以下类方法删除行:
delete_query(self, where_statment, params=None):
query = sqlalchemy.text(f"DELETE FROM {self.tablename} WHERE {where_statment}")
self.execute_query(query=query, params=params)
然后通过下面的代码针对单个条目调用此方法:
where_condition = f"product = '{df['product'][0]}' AND date in ('{','.join(df['date'].unique().tolist())}') "
class.delete_query(where_condition )
我不想使用循环 有什么方法可以在上述设置中的条件下传递这两列?