我有这个python脚本和一些SQL代码,我正在努力制作if语句。我有两个ID,如果它们已经存在,那么Logtext
应该被更新,如果它们不存在,那么它应该用所有信息创建一个新的
TextJobName = str(JenkinsJobName)
TextBuildNr = str(JenkinsBuild)
TextJobId = str(TestJobId)
# Security since Jenkin requires a username and code
urllib3.disable_warnings()
req = requests.get(JenkinsLog_URL, auth=(user, pw), verify=False)
# Puts the console text output in logText
logText = pymysql.escape_string(req.text)
sqlConnection = connectionObject.cursor()
SendingLogFile = f"INSERT INTO testreportingdebug.logtexts(LogTextData, LogID, BuildID, JenkinsJobName) VALUES('{logText}', '{TextJobId}', '{TextBuildNr}', '{TextJobName}');"
sqlConnection.execute(SendingLogFile)
我怎么做这样的东西
SendingLogFile = f"IF testreportingdebug.logtexts(LogID, BuildID) IS SAME AS VALUES('{TextJobId}', '{TextBuildNr}') THEN UPDATE testreportingdebug.logtexts(LogTextData) VALUES('{logText}')
ELSE
INSERT INTO testreportingdebug.logtexts(LogTextData, LogID, BuildID, JenkinsJobName)
VALUES('{logText}', '{TextJobId}', '{TextBuildNr}', '{TextJobName}');"
目前没有回答
相关问题 更多 >
编程相关推荐