dabla commented on issue #38195: URL: https://github.com/apache/airflow/issues/38195#issuecomment-2057482351
> As far as i remember, we recently discuss this case in slack. I guess better introduce `sa_uri` property (or some similar naming) which returns [`sqlalchemy.engine.URL`](https://docs.sqlalchemy.org/en/14/core/engines.html#sqlalchemy.engine.URL) into the `DbApiHook` without any implementation, e.g. raise `NotImplementedError` and implements it per hook which have implementation for SQAlchemy. > > `get_uri` - not clear which URI it is implements, DBApi? SQLAlchemy or even some internal ([ElasticsearchSQLHook](https://github.com/apache/airflow/blob/dec2662190dd4480d0c631da733e19d2ec9a479d/airflow/providers/elasticsearch/hooks/elasticsearch.py#L113)) > > cc: @potiuk @dstandish Why not implement another method named get_url and use that one to instantiate the SQLALchemy engine, as the engine can accept an SQLAlchemy URL object. Also the SQLAlchemy URL class has a factory method named create, which easily allows you to create the URL without the hastle of string manipulations, this is how I did it for my custom SQL operator (the one I mentioned on Slack): ``` def get_url(self) -> URL: return URL.create( self.scheme, username=self.connection.login, password=self.connection.password, host=self.connection.host, port=self.connection.port, ) ``` Also see [here ](https://docs.sqlalchemy.org/en/20/core/engines.html#creating-urls-programmatically)the SQL documentation concerning creating URL's programmatically: [https://docs.sqlalchemy.org/en/20/core/engines.html#creating-urls-programmatically](https://docs.sqlalchemy.org/en/20/core/engines.html#creating-urls-programmatically) -- 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]
