INSERT INTO table(value1, value2)
SELECT 具体数据, 具体数据
FROM DUAL WHERE NOT EXISTS(SELECT value1,value2 FROM table WHERE value1= ?);
sql = 'UPDATE user SET first_name=%s, last_name=%s, affiliation=%s, keywords=%s, gender=%s WHERE user_id=%s'
sql = '''
INSERT INTO user(user_id,first_name,last_name,affiliation,keywords,gender) VALUES (%s,%s,%s,%s,%s,%s)
ON DUPLICATE KEY UPDATE first_name=VALUES(first_name), last_name=VALUES(last_name),
affiliation=VALUES(affiliation), keywords=VALUES(keywords), gender=VALUES(gender)
'''