async for record in acur:
print(record)
+.. versionchanged:: 3.1
-.. warning::
+ `AsyncConnection.connect()` performs DNS name resolution in a non-blocking
+ way.
- `AsyncConnection.connect()` may still block on DNS name resolution.
- To avoid that you should `set the hostaddr connection parameter`__.
+ .. warning::
- The `~psycopg._dns.resolve_hostaddr_async()` is an experimental solution
- to help to do that. Feedback about the feature is welcome!
+ Before version 3.1, `AsyncConnection.connect()` may still block on DNS
+ name resolution. To avoid that you should `set the hostaddr connection
+ parameter`__, or use the `~psycopg._dns.resolve_hostaddr_async()` to
+ do it automatically.
- .. __: https://www.postgresql.org/docs/current/libpq-connect.html
- #LIBPQ-PARAMKEYWORDS
+ .. __: https://www.postgresql.org/docs/current/libpq-connect.html
+ #LIBPQ-PARAMKEYWORDS
.. warning::
.. _dnspython: https://dnspython.readthedocs.io/
-.. function:: resolve_srv
+.. function:: resolve_srv(params)
Apply SRV DNS lookup as defined in :RFC:`2782`.
:param params: The input parameters, for instance as returned by
`~psycopg.conninfo.conninfo_to_dict()`.
+ :type params: `!dict`
:return: An updated list of connection parameters.
For every host defined in the ``params["host"]`` list (comma-separated),
perform SRV lookup also if the the port is the string ``SRV`` (case
insensitive).
- .. warning::
+ .. warning::
This is an experimental functionality.
- .. note::
+ .. note::
One possible way to use this function automatically is to subclass
`~psycopg.Connection`, extending the
`~psycopg.Connection._get_connection_params()` method::
cnn = SrvCognizantConnection.connect("host=_postgres._tcp.db.psycopg.org")
-.. function:: resolve_srv_async
+.. function:: resolve_srv_async(params)
+ :async:
Async equivalent of `resolve_srv()`.
This is an experimental method.
-.. function:: resolve_hostaddr_async
+.. function:: resolve_hostaddr_async(params)
+ :async:
Perform async DNS lookup of the hosts and return a new params dict.
:param params: The input parameters, for instance as returned by
`~psycopg.conninfo.conninfo_to_dict()`.
+ :type params: `!dict`
If a ``host`` param is present but not ``hostname``, resolve the host
addresses dynamically.
.. warning::
Before psycopg 3.1, this function doesn't handle the ``/etc/hosts`` file.
- .. note::
+ .. note::
Starting from psycopg 3.1, a similar operation is performed
automatically by `!AsyncConnection._get_connection_params()`, so this
function is unneeded.