Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SQLAlchemy: How to change a MySQL server system variable using SQLAlchemy?

I want to set the general_log and general_log_file variables using SQLAlchemy, is there a way to do this? I've been Googling around and can't find anything on the topic.

like image 329
HLH Avatar asked Jun 18 '15 22:06

HLH


1 Answers

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")
like image 133
Aleksandr K. Avatar answered Oct 23 '22 19:10

Aleksandr K.