question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

application_name doesn't seem accepted

See original GitHub issue
  • asyncpg version: 0.23.0
  • PostgreSQL version: 12.3
  • **Do you use a PostgreSQL SaaS? **: false
  • Python version: 3.9
  • Platform:
  • Do you use pgbouncer?: false
  • Did you install asyncpg with pip?: true
  • If you built asyncpg locally, which version of Cython did you use?:
  • Can the issue be reproduced under both asyncio and uvloop?:

taking some code written by zzzeek himself https://stackoverflow.com/a/15691283:

create_async_engine(f"postgresql+asyncpg://{user}:{password}@{hostname}/{database_name}?application_name={APPNAME}")

yields

E           TypeError: connect() got an unexpected keyword argument 'application_name'

using instead something I found in an issue here https://github.com/MagicStack/asyncpg/issues/204

    create_async_engine(
        f"postgresql+asyncpg://{user}:{password}@{hostname}/{database_name}",
        server_settings={"application_name": APPNAME},
    )

yields instead

E           TypeError: Invalid argument(s) 'server_settings' sent to create_engine(), using configuration PGDialect_asyncpg/AsyncAdaptedQueuePool/Engine.  Please check that the keyword arguments are appropriate for this combination of components.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

3reactions
elpranscommented, Aug 5, 2021

That said,

    create_async_engine(
        f"postgresql+asyncpg://{user}:{password}@{hostname}/{database_name}",
        connect_args={"server_settings": {"application_name": APPNAME}},
    )

should work

1reaction
elpranscommented, Aug 5, 2021

It’s asyncpg which rejects the application_name parameter

The application_name, like other server-side options should be passed in the server_settings dictionary argument to connect().

In your case, SQLAlchemy is incorrectly interpreting the DSN and tries to pass application_name directly to connect(), and in the explicit argument scenario you should pass it like I’ve shown above.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Why is the application name not being set for my custom role ...
RoleProvider and implemented all the abstract methods and properties. I'm configuring my provider with an applicationName in the web.config, ...
Read more >
Set application name for connection/pool · Issue #204 - GitHub
Hello! A feature request: I would like to be able to set a custom application_name for my connections so that this name displayed...
Read more >
Application name field in info.plist doesn't change display ...
I created a fresh new app to test this and seems that Application name filed in info.plist doesn't really change the display name...
Read more >
Microsoft Search window disapears immediatly after pressing ...
Go to: C:\Users\[username]\AppData\Local\Microsoft\Windows\Fonts · Right click on the folder -> Properties -> Security Tab -> Edit -> Add · Add ...
Read more >
Always set the "applicationName" property when configuring ...
It doesn't throw a connection error, but rather when you attempt to ... ASPNETDB database, and look within the aspnet_Applications table:.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found