You cannot run frappe.delete command from server script. Trust me I already tried. This is the error you will get:
Traceback (most recent call last):
File “apps/frappe/frappe/core/doctype/scheduled_job_type/scheduled_job_type.py”, line 79, in execute
frappe.get_doc(‘Server Script’, script_name).execute_scheduled_method()
File “apps/frappe/frappe/core/doctype/server_script/server_script.py”, line 105, in execute_scheduled_method
safe_exec(self.script)
File “apps/frappe/frappe/utils/safe_exec.py”, line 55, in safe_exec
exec(compile_restricted(script), exec_globals, _locals) # pylint: disable=exec-used
File “”, line 1, in
File “apps/frappe/frappe/utils/safe_exec.py”, line 191, in read_sql
raise frappe.PermissionError(‘Only SELECT SQL allowed in scripting’)
frappe.exceptions.PermissionError: Only SELECT SQL allowed in scripting
You can only call data using frappe.db commands in server script but not modify data directly. You have to write the script server side for it to work.