

def initdb():
    session = settings.Session()
    from airflow import models
    upgradedb()
    merge_conn(models.Connection(conn_id='airflow_db', conn_type='mysql', host='localhost', login='root', password='', schema='airflow'))
    merge_conn(models.Connection(conn_id='airflow_ci', conn_type='mysql', host='localhost', login='root', schema='airflow_ci'))
    merge_conn(models.Connection(conn_id='beeline_default', conn_type='beeline', port='10000', host='localhost', extra='{"use_beeline": true, "auth": ""}', schema='default'))
    merge_conn(models.Connection(conn_id='bigquery_default', conn_type='bigquery'))
    merge_conn(models.Connection(conn_id='local_mysql', conn_type='mysql', host='localhost', login='airflow', password='airflow', schema='airflow'))
    merge_conn(models.Connection(conn_id='presto_default', conn_type='presto', host='localhost', schema='hive', port=3400))
    merge_conn(models.Connection(conn_id='hive_cli_default', conn_type='hive_cli', schema='default'))
    merge_conn(models.Connection(conn_id='hiveserver2_default', conn_type='hiveserver2', host='localhost', schema='default', port=10000))
    merge_conn(models.Connection(conn_id='metastore_default', conn_type='hive_metastore', host='localhost', extra='{"authMechanism": "PLAIN"}', port=9083))
    merge_conn(models.Connection(conn_id='mysql_default', conn_type='mysql', login='root', host='localhost'))
    merge_conn(models.Connection(conn_id='postgres_default', conn_type='postgres', login='postgres', schema='airflow', host='localhost'))
    merge_conn(models.Connection(conn_id='sqlite_default', conn_type='sqlite', host='/tmp/sqlite_default.db'))
    merge_conn(models.Connection(conn_id='http_default', conn_type='http', host='https://www.google.com/'))
    merge_conn(models.Connection(conn_id='mssql_default', conn_type='mssql', host='localhost', port=1433))
    merge_conn(models.Connection(conn_id='vertica_default', conn_type='vertica', host='localhost', port=5433))
    merge_conn(models.Connection(conn_id='webhdfs_default', conn_type='hdfs', host='localhost', port=50070))
    merge_conn(models.Connection(conn_id='ssh_default', conn_type='ssh', host='localhost'))
    KET = models.KnownEventType
    if (not session.query(KET).filter((KET.know_event_type == 'Holiday')).first()):
        session.add(KET(know_event_type='Holiday'))
    if (not session.query(KET).filter((KET.know_event_type == 'Outage')).first()):
        session.add(KET(know_event_type='Outage'))
    if (not session.query(KET).filter((KET.know_event_type == 'Natural Disaster')).first()):
        session.add(KET(know_event_type='Natural Disaster'))
    if (not session.query(KET).filter((KET.know_event_type == 'Marketing Campaign')).first()):
        session.add(KET(know_event_type='Marketing Campaign'))
    session.commit()
    models.DagBag(sync_to_db=True)
    Chart = models.Chart
    chart_label = 'Airflow task instance by type'
    chart = session.query(Chart).filter((Chart.label == chart_label)).first()
    if (not chart):
        chart = Chart(label=chart_label, conn_id='airflow_db', chart_type='bar', x_is_date=False, sql="SELECT state, COUNT(1) as number FROM task_instance WHERE dag_id LIKE 'example%' GROUP BY state")
        session.add(chart)
        session.commit()

dataset/ETHPy150Open airbnb/airflow/airflow/utils/db.py initdb/original