Your Question
I am trying to determine how best to set a variable for AWS Aurora (MySQL) when configuring GORM that would be valid for the entire session, basically running this SET aurora_replica_read_consistency="SESSION". Looked at plugins, but that seems to run for every query or I am not understanding them correctly. Is there a way to initialize and SET a variable like this for the duration of the session?
The document you expected this should be explained
https://gorm.io/docs/session.html
Expected answer
Advice on how to do this in GORM or direction on pursuing it at the driver level.
Comment From: li-jin-gou
use DB.Connection and it ensures that all your database operations are performed using the same connection. go uses connection pooling to manage connections at the bottom.
Comment From: erikkvale
Ok, can you please provide a code example of running a SET using DB.Connection as you describe? Or the relevant link in the documentation? It's not clear from your documentation or code that this is supported.
Comment From: li-jin-gou
refer to https://github.com/go-gorm/gorm/blob/master/tests/connection_test.go#L11