potiuk commented on issue #23701:
URL: https://github.com/apache/airflow/issues/23701#issuecomment-1129109480

   Ah - I think you have wrong expectations.
   
   The connections of Airlow have different URI schemes thatn those of 
sqlalchemy. Many of Airflow connections are not "sqlalchemy" connections and 
they have different semantics - in Airflow, "postgres://" is the only way you 
can refer to postgres conection. This is valid and expected. That's why - the 
connection itself will never return postgresql://. 
   
   I wonder why do you think connection.get_uri() shoudl retturn postgresql:// 
? where this expectation came from? Could you please explain?
   
   What indeed returns postgresql: // is `PostgresHook().get_uri()` - this one 
comes from the fact that PostgresHook derives from DBApi and DBApi.get_uri() is 
used to get SQLAlchemy connection.. But this is DBApi.get_uri() method - which 
is completely different method (it is DBAPi's methodd not Connection's) .While 
the method name is the same, DBApi's get_uri() returns SQLAlachemy URI, not 
Airflow's, that's why we replace postgres://  with postgresql://.
   
   See here:
   
   ```
       def get_sqlalchemy_engine(self, engine_kwargs=None):
           """
           Get an sqlalchemy_engine object.
   
           :param engine_kwargs: Kwargs used in 
:func:`~sqlalchemy.create_engine`.
           :return: the created engine.
           """
           if engine_kwargs is None:
               engine_kwargs = {}
           return create_engine(self.get_uri(), **engine_kwargs)
   ```
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to