reposync/delete_gitlink_issues.py

40 lines
1020 B
Python

import requests
import Token
import mysql.connector
import json
def delete_all_issues(owner, repo, cursor):
url = f"https://gitlink.org.cn/api/v1/{owner}/{repo}/issues/batch_destroy.json"
cursor.execute("SELECT issue_id FROM gitlink_issue")
gitlink_issue_data = cursor.fetchall()
for row in gitlink_issue_data:
payload = json.dumps({
"ids": [
row[0]
]
})
token = Token.getToken()
headers = {
'Authorization': f'Bearer {token}',
'User-Agent': 'Apifox/1.0.0 (https://apifox.com)',
'Content-Type': 'application/json'
}
response = requests.request("DELETE", url, headers=headers, data=payload)
# print(response.text)
print("成功删除gitlink—issues")
# conn = mysql.connector.connect(
# host="localhost",
# user="root",
# password="251226X",
# database="reposyncer"
# )
# cursor = conn.cursor()
# owner= 'wuyifan'
# repo = 'wuyifan-ob-reposyncer'
# delete_all_issues(owner, repo, cursor)