使用数据框列数据删除SQL中的行

使用数据框列数据删除SQL中的行,sql,pandas,dataframe,tuples,delete-row,Sql,Pandas,Dataframe,Tuples,Delete Row,我正在尝试使用数据帧列上的序列号序列删除sql表中的一些行。 尝试下面的代码。但它不断返回/查询失败—并非SQL语句中使用了所有参数/ OSSERIAL = tuple(str(duplicates.OS_SERIAL)) cursor = connection.cursor() sql= "DELETE FROM activealarms WHERE OS_SERIAL= '%s'" cursor.execute(sql,OSSERIAL)

我正在尝试使用数据帧列上的序列号序列删除sql表中的一些行。 尝试下面的代码。但它不断返回/查询失败—并非SQL语句中使用了所有参数/

    OSSERIAL = tuple(str(duplicates.OS_SERIAL))
    cursor = connection.cursor()
    sql= "DELETE FROM activealarms WHERE OS_SERIAL= '%s'"
    cursor.execute(sql,OSSERIAL)
    connection.commit()
    print(cursor.rowcount, "Query Successful")
    cursor.close()

except mysql.connector.Error as error:
    print("Query FAILED {}".format(error))

finally:
    if (connection.is_connected()):
        cursor.close()
        connection.close()
        print("MySQL connection is closed")