New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
CLI Connection import command not work #16374
Comments
I met the same problem and checked the source code. In airflow/cli/commands/connection_command.py it loads connections file as a dict, conn_id for key, Connection type for value. def _import_helper(file_path):
"""Helps import connections from a file"""
connections_dict = load_connections_dict(file_path)
with create_session() as session:
for conn_id, conn_values in connections_dict.items():
# type(conn_id) is str
# type(conn_values) is airflow.models.connection.Connection
if session.query(Connection).filter(Connection.conn_id == conn_id).first():
print(f'Could not import connection {conn_id}: connection already exists.')
continue
allowed_fields = [
'extra',
'description',
'conn_id',
'login',
'conn_type',
'host',
'password',
'schema',
'port',
'uri',
'extra_dejson',
]
filtered_connection_values = {
key: value for key, value in conn_values.items() if key in allowed_fields
}
connection = _create_connection(conn_id, filtered_connection_values)
session.add(connection)
session.commit()
print(f'Imported connection {conn_id}') I guess in the previous version, method load_connections_dict just loads connections file as a json object. In this situation, this code can run correctly. Maybe you should use |
Weirdly enough, from what I can tell with |
You borrowed Guido’s time machine for this one, didn’t you 😉 So I think this can be closed? |
😁 Yes, it can be closed! |
Apache Airflow version:
Kubernetes version (if you are using kubernetes) (use
kubectl version
):Environment:
uname -a
):What happened:
File "/home/airflow/.local/lib/python3.6/site-packages/airflow/cli/commands/connection_command.py", line 272, in _import_helper
key: value for key, value in conn_values.items() if key in allowed_fields
AttributeError: 'Connection' object has no attribute 'items'
I just use the file generated from connections export command
What you expected to happen:
How to reproduce it:
Anything else we need to know:
The text was updated successfully, but these errors were encountered: