def delete_nodes_and_connections_sqla(pks_to_delete):
    """
    Delete all nodes corresponding to pks in the input.
    :param pks_to_delete: A list, tuple or set of pks that should be deleted.
    """
    from aiida.backends.sqlalchemy.models.node import DbNode, DbLink
    from aiida.backends.sqlalchemy.models.group import table_groups_nodes
    from aiida.manage.manager import get_manager
    backend = get_manager().get_backend()
    with backend.transaction() as session:
        stmt = table_groups_nodes.delete().where(table_groups_nodes.c.
            dbnode_id.in_(list(pks_to_delete)))
        session.execute(stmt)
        session.query(DbLink).filter(DbLink.input_id.in_(list(pks_to_delete))
            ).delete(synchronize_session='fetch')
        session.query(DbLink).filter(DbLink.output_id.in_(list(pks_to_delete))
            ).delete(synchronize_session='fetch')
        session.query(DbNode).filter(DbNode.id.in_(list(pks_to_delete))
            ).delete(synchronize_session='fetch')
