-
Notifications
You must be signed in to change notification settings - Fork 90
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
added connect_params to allow any additional parameters that libpg understands #329
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Boosai hi, thanks for the new feature!
Could you also please add the new parameter to any task of any file of any target (say, postgresql_info/tasks/* or postgresql_query/tasks/*) in tests/integration/targets
?
changelogs/fragments/329-postgresql_add_connect_params_field.yml
Outdated
Show resolved
Hide resolved
Co-authored-by: Andrew Klychkov <aaklychkov@mail.ru>
Co-authored-by: Andrew Klychkov <aaklychkov@mail.ru>
Co-authored-by: Andrew Klychkov <aaklychkov@mail.ru>
@Andersson007, I added "connect_timeout=30" via "connect_param" to any tasks there. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Thx, Doug! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
@Boosai thanks for the contribution! |
SUMMARY
Added "connect_params" parameter dict to allow any additional libpg connection parameters.
The postgres library "psycopg" used in this module allows to add
any parameters as kwargs.
The dict "connect_params" can be used to pass in any parameters as kwargs to "psycopg".
https://www.psycopg.org/docs/module.html#psycopg2.connect
This is a more generic approach of PR#324.
ISSUE TYPE
COMPONENT NAME
postgres_*
Affects all modules that establish a database connection.
ADDITIONAL INFORMATION
The key/values of the connect_params parameter dict is passed unmodified as kwargs to the module.
For example:
There is a cluster setup "host1" and "host2". But we do not know which one
of the hosts is the primary (read-write access) and the secondary
(write-only access). In addition we want to set the connection timeout.
We want to insert some data:
We list both hosts in "login_host" and added
"target_session_attrs=read-write" as additional connection parameter to automatically select the
primary.
(Otherwise we would get "cannot execute INSERT in a read-only
transaction" if "host1" is currently the secondary.)
And we set the connection timeout to 10 seconds.
https://www.postgresql.org/docs/current/libpq-connect.html#LIBPQ-CONNSTRING