Skip to content

Instantly share code, notes, and snippets.

@kafran
Created May 31, 2020 18:11
Show Gist options
  • Save kafran/53f0e5ea0433ec9a9c9692304e3263e8 to your computer and use it in GitHub Desktop.
Save kafran/53f0e5ea0433ec9a9c9692304e3263e8 to your computer and use it in GitHub Desktop.
from airflow.utils import db
from airflow.models import Connection
import csv
outfile = open('myconnections.csv', 'w')
outcsv = csv.writer(outfile)
with db.create_session() as session:
connections = session.query(Connection).all()
conn_list = [
[getattr(c, column.name) for column in Connection.__mapper__.columns]
for c in connections
]
outcsv.writerows(conn_list)
outfile.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment