You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
# Get your db instance yada# Set valueawaitdb.one_or_none("select context('application_name', 'my awesome gino application');")
# Get valueawaitdb.one_or_none("select context('application_name');")
Can't test this code ATM, but maybe context vars are the way to go for psql.
Thank you for your response, I am not sure how to do this as a wrapper.
the reason I wanted to pass the parameter in the url so that I don't need to change any of my existing queries.
If you have any idea i would appreciate discussing it and trying it out.
@mpdevilleres I understand the intention to not alter existing queries.
I'm gonna assume you're either using gino with an adapter, such as gino-quart, or directly, which should allow you to manipulate the individual connection.
I'm not sure if you're able to get away without changing queries completely. You might either need to prepend a statement to you queries (no idea how but you could try to play with SQLalchemy) or set a session related variable. I have found on related question on SO.
I would love to further discuss on this but I'm currently busy with studying and my responses might take some time. I hope the above mentioned articles will be helpful. You might also want to open question in asyncpg's repo about this, since it's used under the hood.
Activity
Chaostheorie commentedon May 24, 2021
Have you tried using an approach similar to this answer from SO?
You might just be able to use something like:
Can't test this code ATM, but maybe context vars are the way to go for psql.
You might otherwise need to refer to #683
mpdevilleres commentedon May 30, 2021
Hi @Chaostheorie,
Thank you for your response, I am not sure how to do this as a wrapper.
the reason I wanted to pass the parameter in the url so that I don't need to change any of my existing queries.
If you have any idea i would appreciate discussing it and trying it out.
Thanks,
Chaostheorie commentedon May 30, 2021
@mpdevilleres I understand the intention to not alter existing queries.
I'm gonna assume you're either using gino with an adapter, such as gino-quart, or directly, which should allow you to manipulate the individual connection.
I'm not sure if you're able to get away without changing queries completely. You might either need to prepend a statement to you queries (no idea how but you could try to play with SQLalchemy) or set a session related variable. I have found on related question on SO.
I would love to further discuss on this but I'm currently busy with studying and my responses might take some time. I hope the above mentioned articles will be helpful. You might also want to open question in asyncpg's repo about this, since it's used under the hood.