我试着这样做,但它仍然会提示错误:“连接MySQL时出错无法处理参数:int(2564),必须是list、tuple和类型SQL语句中未使用所有参数”
import mysql.connector
from mysql.connector import Error
import random
try:
fypdb = mysql.connector.connect(host='localhost', port='3306',
database='userdbfyp',
user='root',
password='root')
if fypdb.is_connected():
db_Info = fypdb.get_server_info()
print("Connected to MySQL Server version", db_Info)
tuple = (2564, 5343, 4035, 4496)
randomTup = random.choice(tuple)
cursor = fypdb.cursor()
cursor.execute("UPDATE employee2 SET unCode = (randomTup) WHERE gender = 'm'")
fypdb.commit()
1条答案
按热度按时间0yycz8jy1#
randomTup
的值。