You can execute any raw SQL query which you need (of course you have to get appropriate rights in the session). To change a variable run something like this:
# change variable name and values to what you need
connection.execute("SET SESSION query_cache_type = OFF")
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…