ashb commented on a change in pull request #6426: [AIRFLOW-5751] add get_uri 
method to Connection
URL: https://github.com/apache/airflow/pull/6426#discussion_r338959606
 
 

 ##########
 File path: airflow/models/connection.py
 ##########
 @@ -145,6 +145,38 @@ def parse_from_uri(self, uri):
         if uri_parts.query:
             self.extra = json.dumps(dict(parse_qsl(uri_parts.query, 
keep_blank_values=True)))
 
+    def get_uri(self) -> str:
+        uri = '{}://'.format(self.conn_type.replace('_', '-'))
+
+        authority_block = ''
+        if self.login is not None:
+            authority_block += quote(self.login, safe='')
+
+        if self.password is not None:
+            authority_block += ':' + quote(self.password)
+
+        if authority_block > '':
+            authority_block += '@'
+
+            uri += authority_block
+
+        host_block = ''
+        if self.host:
+            host_block += quote(self.host, safe='')
+
+            if self.port:
+                host_block += ':{}'.format(self.port)
+
+            if self.schema:
 
 Review comment:
   I think schema doesn't depend on host.
   
   For instance `AIRFLOW__CORE__SQLALCHEMY_CONN=postgresql:///airflow`
   
   Should the schema includce the leading `/` already? i.e. do we end up with a 
`//` here?

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to