Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Setting variables on connection #776

Open
Labels
questionA community question, closed when inactive.
@mpdevilleres

Description

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

import asyncpg
con = await asyncpg.connect('postgresql://tenants@localhost:5433/internal?application_name=app_name')
r = await con.fetchrow("SELECT current_setting('application_name')")
Out[1]: <Record current_setting='app_name'>
con = await asyncpg.connect('postgresql://postgres@localhost:5433/internal?options=-c%20app.name%3Dapp_name')
r = await con.fetchrow("SELECT current_setting('app.name')")
r
Out[2]: <Record current_setting='app_name'>

but doing it with gino as shown below doesn't work.

from gino import Gino
db = Gino()
await db.set_bind('postgresql://tenants@localhost:5433/internal?application_name=app_name')
r = await db.all("SELECT current_setting('application_name')")
print(r)
Out[3]: [('',)]
db = Gino()
await db.set_bind('postgresql://postgres@localhost:5433/internal?options=-c%20app.name%3Dapp_name')
r = await db.all("SELECT current_setting('app.name')")
print(r)
Out[4]: asyncpg.exceptions.UndefinedObjectError: unrecognized configuration parameter "app.name"

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionA community question, closed when inactive.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

        AltStyle によって変換されたページ (->オリジナル) /