You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by GitBox <gi...@apache.org> on 2022/03/17 13:18:20 UTC
[GitHub] [airflow] eladkal commented on a change in pull request #22333: Patch sql_alchemy_conn if old postgres scheme used
eladkal commented on a change in pull request #22333:
URL: https://github.com/apache/airflow/pull/22333#discussion_r829106399
##########
File path: airflow/settings.py
##########
@@ -228,6 +229,19 @@ def configure_vars():
global PLUGINS_FOLDER
global DONOT_MODIFY_HANDLERS
SQL_ALCHEMY_CONN = conf.get('core', 'SQL_ALCHEMY_CONN')
+
+ # as of sqlalchemy 1.4, scheme `postgres+psycopg2` must be replaced with `postgresql`
+ parsed = urlparse(SQL_ALCHEMY_CONN)
+ bad_scheme = 'postgres+psycopg2'
+ if parsed.scheme == bad_scheme:
+ warnings.warn(
+ f"Scheme for metadata sql alchemy connection is `{bad_scheme}`."
+ "As of sqlalchemy 1.4 this is no longer supported. You must change "
+ "to `postgresql`",
+ PendingDeprecationWarning,
Review comment:
We probably should.
By the way sqlalchemy does something really nice where it makes it's own deprecation warnning with specific class
https://github.com/sqlalchemy/sqlalchemy/blob/769fa67d842035dd852ab8b6a26ea3f110a51131/lib/sqlalchemy/exc.py#L779
for example:
`[2022-03-17 09:02:03,734] {logging_mixin.py:115} WARNING - /opt/***/***/models/dag.py:1084 SADeprecationWarning: Query.value() is deprecated and will be removed in a future release. Please use Query.with_entities() in combination with Query.scalar() (deprecated since: 1.4)`
It's very nice to know what package originated the warning.
--
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: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org