PostgreSQL Connection Options (application_name)

  • Goal: I'd like the ability to know whether a query running against a DB is coming from retool vs another source.

  • Steps: I tried using the connection options key-value field, with application_name = retool. However, when I look at the requests being sent to the backend, that field is not populating.

  • Details: I'm curious whether people have successfully populated the application_name field in a PostgreSQL resource, or whether there is another creative way to tag all queries through this resource for attribution.

Thanks in advance!

2 Likes

Hello @Simon_Horowitz , Welcome to Retool community.

Use SET application_name in Your Queries

You can explicitly set the application_name for each session by adding the following line to the beginning of your query in Retool:

SET application_name = 'Retool';
-- Your actual query
SELECT * FROM your_table;

This ensures that the application_name is included for all queries in that session.

3 Likes

Thank you so much for the help! Just confirming there's no way to set this on the resource directly? If not I'll go add this to each query, thanks again.

1 Like

Hey @Simon_Horowitz ,

Unfortunately, there is no native way in Retool to set application_name at the resource level directly in the PostgreSQL resource configuration. Retool doesn’t currently provide an option to pass custom connection parameters like application_name automatically for all queries at the resource level.

2 Likes