This is an automated email from the ASF dual-hosted git repository.

jasonliu pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/airflow.git


The following commit(s) were added to refs/heads/main by this push:
     new 79733e91cf9 Fix apache#47555: PostgreSQL URI driver issue  (#47709)
79733e91cf9 is described below

commit 79733e91cf995bb3d4792f3e17d7a97935db85ea
Author: Dong-yeong0 <[email protected]>
AuthorDate: Thu Mar 20 22:55:23 2025 +0900

    Fix apache#47555: PostgreSQL URI driver issue  (#47709)
    
    * Fix apache#47555: PostgreSQL URI scheme issue
    
    * Fix: allow configuring PostgreSQL connection driver
    
    Added support for customizing the PostgreSQL connection driver (`postgres` 
vs `postgresql`)
    via the `postgres_driver` option in the extra JSON field.
    
    * Fix apache#47555: PostgreSQL URI scheme issue
    
    * Fix: allow configuring PostgreSQL connection driver
    
    Added support for customizing the PostgreSQL connection driver (`postgres` 
vs `postgresql`)
    via the `postgres_driver` option in the extra JSON field.
    
    * Add the documentation for the 'designator' parameter in the PostgreSQL 
extras section
    
    * Remove the code that constructs the URI based on connection type
    
    * Update get_uri method docstring
    
    * Clarify that get_uri() does not return a SQLAlchemy URI
    
    * Fix rst-backticks
    
    * Remove designer description
    
    * Fix format code with ruff
    
    ---------
    
    Co-authored-by: LIU ZHE YOU <[email protected]>
---
 airflow/models/connection.py             | 8 +++++++-
 docs/apache-airflow/howto/connection.rst | 4 ++++
 2 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/airflow/models/connection.py b/airflow/models/connection.py
index 5b10e1b1843..37a0865014c 100644
--- a/airflow/models/connection.py
+++ b/airflow/models/connection.py
@@ -247,7 +247,13 @@ class Connection(Base, LoggingMixin):
         return host
 
     def get_uri(self) -> str:
-        """Return connection in URI format."""
+        """
+        Return the connection URI in Airflow format.
+
+        The Airflow URI format examples: 
https://airflow.apache.org/docs/apache-airflow/stable/howto/connection.html#uri-format-example
+
+        Note that the URI returned by this method is **not** 
SQLAlchemy-compatible, if you need a SQLAlchemy-compatible URI, use the 
:attr:`~airflow.providers.common.sql.hooks.sql.DbApiHook.sqlalchemy_url`
+        """
         if self.conn_type and "_" in self.conn_type:
             self.log.warning(
                 "Connection schemes (type: %s) shall not contain '_' according 
to RFC3986.",
diff --git a/docs/apache-airflow/howto/connection.rst 
b/docs/apache-airflow/howto/connection.rst
index f90f7e96b10..d0cc058a430 100644
--- a/docs/apache-airflow/howto/connection.rst
+++ b/docs/apache-airflow/howto/connection.rst
@@ -419,6 +419,10 @@ convenience method 
:py:meth:`~airflow.models.connection.Connection.get_uri`.  It
     >>> print(f"AIRFLOW_CONN_{c.conn_id.upper()}='{c.get_uri()}'")
     
AIRFLOW_CONN_SOME_CONN='mysql://myname:[email protected]?this_param=some+val&that_param=other+val%2A'
 
+.. note::
+
+   The ``get_uri()`` method return the connection URI in Airflow format, 
**not** a SQLAlchemy-compatible URI. if you need a SQLAlchemy-compatible URI 
for database connections, use 
:attr:`~airflow.providers.common.sql.hooks.sql.DbApiHook.sqlalchemy_url` 
property instead.
+
 Additionally, if you have created a connection, you can use ``airflow 
connections get`` command.
 
 .. code-block:: console

Reply via email to