-
Notifications
You must be signed in to change notification settings - Fork 150
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Setting variables on connection #776
Comments
Have you tried using an approach similar to this answer from SO? You might just be able to use something like: # Get your db instance yada
# Set value
await db.one_or_none("select context('application_name', 'my awesome gino application');")
# Get value
await db.one_or_none("select context('application_name');") 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 |
Hi @Chaostheorie, Thank you for your response, I am not sure how to do this as a wrapper. If you have any idea i would appreciate discussing it and trying it out. Thanks, |
@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. |
Greetings,
I have a use case where I need to set the variable for each session or connection.
and I am able to accomplish it using the asyncpg directly
but doing it with gino as shown below doesn't work.
I also tried passing
connect_args={"application_name":"myapp"}
as recommended by zzzeek on set_bind. but I still fail to make it work.Is there anyway for gino to achieve my use case?
The text was updated successfully, but these errors were encountered: