0

How can I set the application name when connection to Postgres with the psqLODBC driver?

You get the application name from pg_stat_activity.application_name.

I tried different Parameters in the connection string.

APP=...; application_name=...; APP_NAME=... in all different variations.

Nothings works and pg_stat_activity.application_name always returns an empty string.

6
  • Given that the documentation does not list a property for that: you could run set application_name = 'doev'; after the connection is established Commented Sep 11, 2018 at 11:37
  • No, the documentation has no hint. And I have no idea, how I can use 'set' in my environment. Commented Sep 11, 2018 at 14:47
  • It's a SQL statement, run it like any other SQL statement. Commented Sep 11, 2018 at 14:47
  • thank you. After I found out, how to open a odbc connection by vba-code, I could use your solution. I think I will delete this question in some time. Commented Sep 12, 2018 at 7:46
  • application_name=... would be the correct syntax in a regular connection string , but those semicolons and upper-case letters must be a windows thing - what name are you trying to set? Commented Sep 12, 2018 at 7:47

1 Answer 1

3

Once you have established a connection in your application, you can run a SQL statement to change the application_name dynamically.

set application_name = 'doev';

You run that just like any other statement (that does not return a result) with your programming language. But remember if you have turned off autocommit in your connection, you need to commit that SET statement. If you are running in autocommit mode, that is not necessary.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.