feluelle commented on code in PR #28721:
URL: https://github.com/apache/airflow/pull/28721#discussion_r1061452130


##########
airflow/providers/sqlite/hooks/sqlite.py:
##########
@@ -33,13 +34,16 @@ class SqliteHook(DbApiHook):
 
     def get_conn(self) -> sqlite3.dbapi2.Connection:
         """Returns a sqlite connection object"""
-        conn_id = getattr(self, self.conn_name_attr)
-        airflow_conn = self.get_connection(conn_id)
-        conn = sqlite3.connect(airflow_conn.host)
+        # The sqlite3 connection does not use the sqlite prefix.
+        # See 
https://docs.sqlalchemy.org/en/14/dialects/sqlite.html#connect-strings for 
details.
+        uri = self.get_uri().replace("sqlite:///", "")
+        conn = sqlite3.connect(uri)
         return conn
 
     def get_uri(self) -> str:
         """Override DbApiHook get_uri method for get_sqlalchemy_engine()"""
-        conn_id = getattr(self, self.conn_name_attr)
-        airflow_conn = self.get_connection(conn_id)
-        return f"sqlite:///{airflow_conn.host}"
+        # The sqlite connection has one more slash for path specification.
+        # See 
https://docs.sqlalchemy.org/en/14/dialects/sqlite.html#uri-connections for 
details.
+        uri = super().get_uri().replace("sqlite://", "sqlite:///")
+        raw_uri = unquote(uri)
+        return raw_uri

Review Comment:
   No, it does not change the output. We have tests which validates that 
[here](https://github.com/apache/airflow/pull/28721/files#diff-3614936e10a5d7aa9916f548b547cf3443f8ea29e30558d6fe55176e0a6f702eR30).



-- 
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