[Python] How to delete records that are being selected at the same time using Flask-SQLAlchemy

Discussão em 'Python' iniciado por Stack, Março 2, 2025.

  1. Stack

    Stack Membro Participativo

    I'm trying to mimic this query:

    DELETE FROM files WHERE id IN (SELECT id FROM files WHERE patient_id=X);


    But I fail to do it using this as this only deletes a single record:

    obj = File.query.filter_by(patient_id=X).delete()
    session.delete(obj)
    session.commit()

    Continue reading...

Compartilhe esta Página