I\'m using SQLAlchemy for a project, and need to be able to specify a session variable/setting for one specific call for performance reasons:
set session max
None of the above worked for me. but this worked:
engine_type: str = 'mysql+mysqlconnector'
db_user_name: str = ''
db_user_password: str = ''
db_server: str = ''
db_name: str = ''
engine: sqlalchemy.engine.Engine = create_engine(
f'{engine_type}://{db_user_name}:{db_user_password}@{db_server}:3306/{db_name}'
)
engine.execute("SHOW VARIABLES like 'group_concat_max_len'").fetchone()
('group_concat_max_len', '1024')
engine.execute("SET SESSION group_concat_max_len=10240")
engine.execute("SHOW VARIABLES like 'group_concat_max_len'").fetchone()
('group_concat_max_len', '10240')
this must happen right before the query is performed.