import mysql.connector.pooling
config={
"host":"localhost",
"port":3306,
"user":"root",
"password":"abc123456",
"database":"demo"
}
# 连接数据库
con = mysql.connector.connect(**config)
try:
# 创建连接池
pool=mysql.connector.pooling.MySQLConnectionPool(**config,pool_size=10)
# 获取连接
con=pool.get_connection()
con.start_transaction()
cursor = con.cursor()
sql = "UPDATE t_emp SET sal=sal+%s WHERE deptno=%s"
cursor.execute(sql,(200,20))
con.commit()
except Exception as e:
print(e)